@crombolo/backoffice-host 0.61.0 → 0.63.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 +3 -3
- package/plugin/app-preview/umbraco-package.json +1 -1
- package/plugin/bundles-installed.js +8 -2
- package/plugin/bundles-level-words.js +9 -0
- package/plugin/bundles-marketplace.js +2 -2
- package/plugin/bundles-signature-words.js +14 -3
- package/plugin/ci-access-words.js +3 -3
- package/plugin/content-settings-dashboard.js +69 -0
- package/plugin/forms-client.js +7 -0
- package/plugin/forms-overview.js +79 -0
- package/plugin/forms-workflows.js +18 -0
- package/plugin/group-editor-words.js +294 -0
- package/plugin/group-editor.js +729 -0
- package/plugin/localizations/umbraco-package.json +1 -1
- package/plugin/seo/umbraco-package.json +1 -1
- package/plugin/settings-cards.js +14 -17
- package/plugin/sign-in/umbraco-package.json +1 -1
- package/plugin/umbraco-package.json +39 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crombolo/backoffice-host",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.63.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",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@crombolo/core": "0.
|
|
36
|
-
"@crombolo/backoffice-dist": "0.
|
|
35
|
+
"@crombolo/core": "0.63.0",
|
|
36
|
+
"@crombolo/backoffice-dist": "0.63.0"
|
|
37
37
|
}
|
|
38
38
|
}
|
|
@@ -28,7 +28,13 @@ import {
|
|
|
28
28
|
} from './bundles-client.js'
|
|
29
29
|
import './bundles-activity.js'
|
|
30
30
|
import { levelBlock, levelStyles } from './bundles-level.js'
|
|
31
|
-
import {
|
|
31
|
+
import {
|
|
32
|
+
configSnippet,
|
|
33
|
+
grantChoice,
|
|
34
|
+
levelWords,
|
|
35
|
+
unvouchedLine,
|
|
36
|
+
vouchState,
|
|
37
|
+
} from './bundles-level-words.js'
|
|
32
38
|
import { signatureBlock, signatureStyles, signatureWords } from './bundles-signature.js'
|
|
33
39
|
|
|
34
40
|
/** Where each part of a bundle stands on this site, in the words of someone running it. */
|
|
@@ -257,7 +263,7 @@ export default class CromboloBundlesInstalledElement extends UmbLitElement {
|
|
|
257
263
|
/** What it may do with the site, who approved it, and the button that turns it off or on. */
|
|
258
264
|
#permissions(item) {
|
|
259
265
|
const state = item.provenance?.state
|
|
260
|
-
const choice = grantChoice(item.level, this._mayGrant,
|
|
266
|
+
const choice = grantChoice(item.level, this._mayGrant, vouchState(item.provenance))
|
|
261
267
|
const approved = item.granted
|
|
262
268
|
? item.granted.by === "the site's code"
|
|
263
269
|
? `Developer installed, on ${new Date(item.granted.at).toLocaleDateString()}.`
|
|
@@ -52,6 +52,10 @@ export function groupLines(groups) {
|
|
|
52
52
|
export const NOBODY_VOUCHED = 'Nobody has vouched for who built this'
|
|
53
53
|
const VOUCHED = new Set(['signed', 'vouched', 'local'])
|
|
54
54
|
|
|
55
|
+
/** What vouches for it: a signature counts only when its signer is trusted here (story 335). */
|
|
56
|
+
export const vouchState = (provenance) =>
|
|
57
|
+
provenance?.state === 'signed' && provenance.trusted !== true ? 'untrusted' : provenance?.state
|
|
58
|
+
|
|
55
59
|
/**
|
|
56
60
|
* Whether this person may turn it on here, and if not what to show in place of
|
|
57
61
|
* the button: an administrator's sentence, the unvouched sentence, or the
|
|
@@ -62,6 +66,11 @@ export function grantChoice(level, may, provenanceState) {
|
|
|
62
66
|
if (rule === 'config') return { snippet: true }
|
|
63
67
|
if (rule !== 'yes') return { sentence: 'An administrator can turn this on.' }
|
|
64
68
|
if (level === 'limited' || !level) return { grant: true }
|
|
69
|
+
if (provenanceState === 'untrusted')
|
|
70
|
+
return {
|
|
71
|
+
sentence:
|
|
72
|
+
"It's signed by someone this site doesn't trust, so it can't be turned on here. An administrator can add the signer in Settings → Trusted signers.",
|
|
73
|
+
}
|
|
65
74
|
if (!VOUCHED.has(provenanceState))
|
|
66
75
|
return { sentence: `${NOBODY_VOUCHED}, so it can't be turned on here.` }
|
|
67
76
|
return { grant: true }
|
|
@@ -18,7 +18,7 @@ import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'
|
|
|
18
18
|
import { carriesTags } from './bundles-carries.js'
|
|
19
19
|
import { bundleSignature, installBundle, searchMarketplace } from './bundles-client.js'
|
|
20
20
|
import { levelBlock, levelStyles } from './bundles-level.js'
|
|
21
|
-
import { configSnippet, grantChoice, unvouchedLine } from './bundles-level-words.js'
|
|
21
|
+
import { configSnippet, grantChoice, unvouchedLine, vouchState } from './bundles-level-words.js'
|
|
22
22
|
import { signatureBlock, signatureStyles, signatureWords } from './bundles-signature.js'
|
|
23
23
|
|
|
24
24
|
export default class CromboloBundlesMarketplaceElement extends UmbLitElement {
|
|
@@ -238,7 +238,7 @@ export default class CromboloBundlesMarketplaceElement extends UmbLitElement {
|
|
|
238
238
|
#consent(item) {
|
|
239
239
|
const checked = this._signatures.get(item.name)
|
|
240
240
|
const state = checked?.provenance?.state
|
|
241
|
-
const choice = grantChoice(this._level, this._mayGrant,
|
|
241
|
+
const choice = grantChoice(this._level, this._mayGrant, vouchState(checked?.provenance))
|
|
242
242
|
return html`
|
|
243
243
|
<div class="consent" role="group" aria-label="What it asks for">
|
|
244
244
|
${levelBlock({
|
|
@@ -7,7 +7,8 @@ const refName = (ref) => (ref ?? '').replace(/^refs\/(tags|heads)\//, '')
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @param {{ state: string, source?: { repository: string, ref: string, commit: string },
|
|
10
|
-
* links?: { commit?: string, tag?: string | null, run?: string | null }, reason?: string
|
|
10
|
+
* links?: { commit?: string, tag?: string | null, run?: string | null }, reason?: string,
|
|
11
|
+
* key?: { comment?: string, fingerprint: string }, trusted?: boolean }} provenance
|
|
11
12
|
* @param {string | null | undefined} refused why this site would not install it, when it would not
|
|
12
13
|
* @param {{ signatures?: string, sources?: string[] } | undefined} policy
|
|
13
14
|
* @returns {{ tone: string, label: string, detail: string, links: { label: string, href: string }[], refusal: string }}
|
|
@@ -17,14 +18,24 @@ export function signatureWords(provenance, refused, policy) {
|
|
|
17
18
|
let tone = 'default'
|
|
18
19
|
let label = 'Not signed'
|
|
19
20
|
let detail = "Nobody has signed this bundle, so where it was built can't be checked."
|
|
21
|
+
// Story 335: whether this site trusts who signed it, which only a trusted signer's signature vouches for.
|
|
22
|
+
const trust = (trusted) =>
|
|
23
|
+
trusted
|
|
24
|
+
? ' This site trusts its signer.'
|
|
25
|
+
: " This site doesn't trust its signer: an administrator can add it in Settings → Trusted signers."
|
|
20
26
|
if (provenance?.state === 'signed' && provenance.source) {
|
|
21
27
|
const { repository, ref, commit } = provenance.source
|
|
22
|
-
tone = 'positive'
|
|
28
|
+
tone = provenance.trusted ? 'positive' : 'default'
|
|
23
29
|
label = 'Signed'
|
|
24
|
-
detail = `Built from github.com/${repository} at ${refName(ref)} (${short(commit)})
|
|
30
|
+
detail = `Built from github.com/${repository} at ${refName(ref)} (${short(commit)}).${trust(provenance.trusted)}`
|
|
25
31
|
if (provenance.links?.commit) links.push({ label: 'Commit', href: provenance.links.commit })
|
|
26
32
|
if (provenance.links?.tag) links.push({ label: 'Release', href: provenance.links.tag })
|
|
27
33
|
if (provenance.links?.run) links.push({ label: 'Build', href: provenance.links.run })
|
|
34
|
+
} else if (provenance?.state === 'signed' && provenance.key) {
|
|
35
|
+
const { comment, fingerprint } = provenance.key
|
|
36
|
+
tone = provenance.trusted ? 'positive' : 'default'
|
|
37
|
+
label = 'Signed'
|
|
38
|
+
detail = `Signed with the key ${comment ? `${comment} ` : ''}(${fingerprint}).${trust(provenance.trusted)}`
|
|
28
39
|
} else if (provenance?.state === 'local') {
|
|
29
40
|
label = 'From this site'
|
|
30
41
|
detail = "Linked from this site's own code, not from a package registry."
|
|
@@ -20,14 +20,14 @@ export const CI_PERMISSIONS = [
|
|
|
20
20
|
},
|
|
21
21
|
{
|
|
22
22
|
verb: 'Crombolo.Remote.ApplyStructure',
|
|
23
|
-
label: 'Change structure
|
|
24
|
-
explain: '
|
|
23
|
+
label: 'Change structure',
|
|
24
|
+
explain: 'Apply a bundle that changes its types, stylesheets or scripts.',
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
27
|
verb: 'Crombolo.Remote.InstallCode',
|
|
28
28
|
label: 'Install code',
|
|
29
29
|
explain:
|
|
30
|
-
'Install extensions,
|
|
30
|
+
'Install extensions, the code and templates a site package carries, and push a whole site: all of these run on the server.',
|
|
31
31
|
},
|
|
32
32
|
]
|
|
33
33
|
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content settings: one card for how pages are addressed, with tabs for the
|
|
3
|
+
* addresses themselves, the redirects recorded or configured for them, and the
|
|
4
|
+
* relations between items. Each tab is the screen that was a card of its own.
|
|
5
|
+
*/
|
|
6
|
+
import { css, html } from '@umbraco-cms/backoffice/external/lit'
|
|
7
|
+
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'
|
|
8
|
+
import './addresses-dashboard.js'
|
|
9
|
+
|
|
10
|
+
export const CONTENT_SETTINGS_TABS = [
|
|
11
|
+
{ id: 'urls', label: 'URLs' },
|
|
12
|
+
{ id: 'redirects', label: 'Page Redirects' },
|
|
13
|
+
{ id: 'relations', label: 'Relations' },
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
const REDIRECTS_DASHBOARD = 'Umb.Dashboard.RedirectManagement'
|
|
17
|
+
const RELATION_TYPES = 'Umb.Collection.RelationType'
|
|
18
|
+
|
|
19
|
+
export default class CromboloContentSettingsDashboardElement extends UmbLitElement {
|
|
20
|
+
static properties = {
|
|
21
|
+
_tab: { state: true },
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
constructor() {
|
|
25
|
+
super()
|
|
26
|
+
this._tab = 'urls'
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
#panel() {
|
|
30
|
+
if (this._tab === 'redirects')
|
|
31
|
+
return html`<umb-extension-slot
|
|
32
|
+
type="dashboard"
|
|
33
|
+
.filter=${(manifest) => manifest.alias === REDIRECTS_DASHBOARD}></umb-extension-slot>`
|
|
34
|
+
if (this._tab === 'relations')
|
|
35
|
+
return html`<div class="padded"><umb-collection alias=${RELATION_TYPES}></umb-collection></div>`
|
|
36
|
+
return html`<crombolo-addresses-dashboard></crombolo-addresses-dashboard>`
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
render() {
|
|
40
|
+
return html`
|
|
41
|
+
<uui-tab-group>
|
|
42
|
+
${CONTENT_SETTINGS_TABS.map(
|
|
43
|
+
(tab) => html`<uui-tab
|
|
44
|
+
label=${tab.label}
|
|
45
|
+
?active=${this._tab === tab.id}
|
|
46
|
+
@click=${() => {
|
|
47
|
+
this._tab = tab.id
|
|
48
|
+
}}>${tab.label}</uui-tab>`,
|
|
49
|
+
)}
|
|
50
|
+
</uui-tab-group>
|
|
51
|
+
${this.#panel()}
|
|
52
|
+
`
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
static styles = css`
|
|
56
|
+
:host { display: block; }
|
|
57
|
+
uui-tab-group {
|
|
58
|
+
padding: 0 var(--uui-size-layout-1);
|
|
59
|
+
border-bottom: 1px solid var(--uui-color-border);
|
|
60
|
+
background: var(--uui-color-surface);
|
|
61
|
+
}
|
|
62
|
+
.padded { padding: var(--uui-size-layout-1); }
|
|
63
|
+
`
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
customElements.define(
|
|
67
|
+
'crombolo-content-settings-dashboard',
|
|
68
|
+
CromboloContentSettingsDashboardElement,
|
|
69
|
+
)
|
package/plugin/forms-client.js
CHANGED
|
@@ -67,6 +67,13 @@ export const previewChoices = (source) =>
|
|
|
67
67
|
/** Every dictionary item, with its words in the default language. */
|
|
68
68
|
export const listWords = async () => (await call('/words')).body.words ?? []
|
|
69
69
|
|
|
70
|
+
/** Sets a send-to-URL workflow's secret header (story 304), or with no value removes it. */
|
|
71
|
+
export const setSecretHeader = (form, workflow, header, value) =>
|
|
72
|
+
call(
|
|
73
|
+
`/${encodeURIComponent(form)}/workflows/${encodeURIComponent(workflow)}/secrets/${encodeURIComponent(header)}`,
|
|
74
|
+
value === undefined ? { method: 'DELETE' } : { method: 'PUT', body: JSON.stringify({ value }) },
|
|
75
|
+
)
|
|
76
|
+
|
|
70
77
|
export const deleteForm = (key) => call(`/${encodeURIComponent(key)}`, { method: 'DELETE' })
|
|
71
78
|
|
|
72
79
|
export const listEntries = async (key, query = {}) => {
|
package/plugin/forms-overview.js
CHANGED
|
@@ -29,6 +29,7 @@ import {
|
|
|
29
29
|
previewChoices,
|
|
30
30
|
readForm,
|
|
31
31
|
saveForm,
|
|
32
|
+
setSecretHeader,
|
|
32
33
|
} from './forms-client.js'
|
|
33
34
|
import {
|
|
34
35
|
addGroup,
|
|
@@ -52,6 +53,8 @@ import {
|
|
|
52
53
|
addWorkflow,
|
|
53
54
|
describeProblemPath,
|
|
54
55
|
removeWorkflow,
|
|
56
|
+
secretHeaderNames,
|
|
57
|
+
setSecretHeaderName,
|
|
55
58
|
setWorkflowName,
|
|
56
59
|
setWorkflowSetting,
|
|
57
60
|
setWorkflowTrigger,
|
|
@@ -99,6 +102,7 @@ export default class CromboloFormsOverviewElement extends UmbLitElement {
|
|
|
99
102
|
_types: { state: true },
|
|
100
103
|
_workflowTypes: { state: true },
|
|
101
104
|
_designs: { state: true },
|
|
105
|
+
_secrets: { state: true },
|
|
102
106
|
_because: { state: true },
|
|
103
107
|
_tab: { state: true },
|
|
104
108
|
}
|
|
@@ -183,6 +187,7 @@ export default class CromboloFormsOverviewElement extends UmbLitElement {
|
|
|
183
187
|
this._tab = 'design'
|
|
184
188
|
const detail = await readForm(key)
|
|
185
189
|
this._editing = withLayout(detail.definition)
|
|
190
|
+
this._secrets = detail.secrets ?? []
|
|
186
191
|
this._choices = new Map()
|
|
187
192
|
for (const field of this.#fields) if (field.source) this.#preview(field)
|
|
188
193
|
}
|
|
@@ -792,9 +797,73 @@ export default class CromboloFormsOverviewElement extends UmbLitElement {
|
|
|
792
797
|
${hint}
|
|
793
798
|
</label>`
|
|
794
799
|
})}
|
|
800
|
+
${workflow.type === 'sendToUrl' ? this.#secretHeaders(workflow, index) : nothing}
|
|
795
801
|
</div>`
|
|
796
802
|
}
|
|
797
803
|
|
|
804
|
+
/** Headers kept sealed on the site and sent only to the address they were set for (story 304). */
|
|
805
|
+
#secretHeaders(workflow, index) {
|
|
806
|
+
const names = secretHeaderNames(workflow)
|
|
807
|
+
return html`<div class="secret-headers">
|
|
808
|
+
<span>Secret headers</span>
|
|
809
|
+
<small class="offered">For a key or token the address needs. Kept on this site, never shown again, and sent only to the address above: change the address and set them again.</small>
|
|
810
|
+
${names.map((name) => {
|
|
811
|
+
const saved = (this._secrets ?? []).find(
|
|
812
|
+
(secret) => secret.workflow === workflow.key && secret.header === name,
|
|
813
|
+
)
|
|
814
|
+
return html`<div class="secret-header">
|
|
815
|
+
<code>${name}</code>
|
|
816
|
+
<span>${saved ? (saved.set ? 'Set' : 'Not set') : 'Save the form, then set it'}</span>
|
|
817
|
+
${
|
|
818
|
+
saved
|
|
819
|
+
? html`<uui-input
|
|
820
|
+
type="password"
|
|
821
|
+
label=${`A value for ${name}`}
|
|
822
|
+
placeholder=${saved.set ? 'Replace it' : 'Its value'}
|
|
823
|
+
@change=${(event) => this.#setSecret(workflow, name, event.target.value)}
|
|
824
|
+
></uui-input>`
|
|
825
|
+
: nothing
|
|
826
|
+
}
|
|
827
|
+
${
|
|
828
|
+
saved?.set
|
|
829
|
+
? html`<uui-button compact look="secondary" label="Clear"
|
|
830
|
+
@click=${() => this.#setSecret(workflow, name, undefined)}></uui-button>`
|
|
831
|
+
: nothing
|
|
832
|
+
}
|
|
833
|
+
<uui-button compact look="secondary" color="danger" label=${`Stop sending ${name}`}
|
|
834
|
+
@click=${() => this.#apply(setSecretHeaderName, index, name, false)}></uui-button>
|
|
835
|
+
</div>`
|
|
836
|
+
})}
|
|
837
|
+
<uui-input
|
|
838
|
+
label="Add a secret header"
|
|
839
|
+
placeholder="Its name, such as Authorization"
|
|
840
|
+
@change=${(event) => {
|
|
841
|
+
const name = event.target.value.trim()
|
|
842
|
+
if (!name) return
|
|
843
|
+
this.#apply(setSecretHeaderName, index, name, true)
|
|
844
|
+
event.target.value = ''
|
|
845
|
+
}}
|
|
846
|
+
></uui-input>
|
|
847
|
+
</div>`
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
async #setSecret(workflow, header, value) {
|
|
851
|
+
if (value === '') return
|
|
852
|
+
try {
|
|
853
|
+
const result = await setSecretHeader(this._editing.key, workflow.key, header, value)
|
|
854
|
+
if (!result.ok) {
|
|
855
|
+
this._notice = result.body.message ?? 'That header could not be set.'
|
|
856
|
+
return
|
|
857
|
+
}
|
|
858
|
+
this.#notifications?.peek('positive', {
|
|
859
|
+
data: { message: value === undefined ? `${header} cleared` : `${header} set` },
|
|
860
|
+
})
|
|
861
|
+
this._secrets = (await readForm(this._editing.key)).secrets ?? []
|
|
862
|
+
} catch (error) {
|
|
863
|
+
this._notice = error.message
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
|
|
798
867
|
#touch() {
|
|
799
868
|
// Lit tracks the reference, not what is inside it.
|
|
800
869
|
this._editing = { ...this._editing }
|
|
@@ -1120,6 +1189,16 @@ export default class CromboloFormsOverviewElement extends UmbLitElement {
|
|
|
1120
1189
|
gap: var(--uui-size-space-3, 9px);
|
|
1121
1190
|
max-width: 60ch;
|
|
1122
1191
|
}
|
|
1192
|
+
.secret-headers {
|
|
1193
|
+
display: grid;
|
|
1194
|
+
gap: var(--uui-size-space-2, 6px);
|
|
1195
|
+
}
|
|
1196
|
+
.secret-header {
|
|
1197
|
+
display: flex;
|
|
1198
|
+
flex-wrap: wrap;
|
|
1199
|
+
align-items: center;
|
|
1200
|
+
gap: var(--uui-size-space-3, 9px);
|
|
1201
|
+
}
|
|
1123
1202
|
.workflow-settings label,
|
|
1124
1203
|
.workflow-settings .switch {
|
|
1125
1204
|
display: grid;
|
|
@@ -145,3 +145,21 @@ export function describeProblemPath(form, path, types = new Map()) {
|
|
|
145
145
|
)
|
|
146
146
|
return `${name}: ${setting?.label ?? FILE_ONLY_LABELS[found[2]] ?? found[2]}`
|
|
147
147
|
}
|
|
148
|
+
|
|
149
|
+
/** The headers a send-to-URL workflow keeps sealed on the site (story 304). */
|
|
150
|
+
export const secretHeaderNames = (workflow) =>
|
|
151
|
+
Object.entries(workflow.settings?.headers ?? {})
|
|
152
|
+
.filter(([, value]) => value && typeof value === 'object' && value.secret === true)
|
|
153
|
+
.map(([name]) => name)
|
|
154
|
+
|
|
155
|
+
/** Names a header as secret, or with `secret` false takes it out. */
|
|
156
|
+
export const setSecretHeaderName = (form, index, name, secret) =>
|
|
157
|
+
replace(form, index, (workflow) => {
|
|
158
|
+
const headers = { ...(workflow.settings?.headers ?? {}) }
|
|
159
|
+
if (secret) headers[name] = { secret: true }
|
|
160
|
+
else delete headers[name]
|
|
161
|
+
const settings = { ...workflow.settings }
|
|
162
|
+
if (Object.keys(headers).length > 0) settings.headers = headers
|
|
163
|
+
else delete settings.headers
|
|
164
|
+
return { settings }
|
|
165
|
+
})
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the user group editor says and how its choices become verbs (story 338).
|
|
3
|
+
* Pure, so the unit tests read it outside a browser and hold its levels to the
|
|
4
|
+
* server's (`@crombolo/core`, `permission-levels.ts`).
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export const TABS = [
|
|
8
|
+
{ id: 'access', label: 'Access' },
|
|
9
|
+
{ id: 'permissions', label: 'Permissions' },
|
|
10
|
+
{ id: 'exceptions', label: 'Exceptions' },
|
|
11
|
+
{ id: 'transfer', label: 'Data Transfer', adminOnly: true },
|
|
12
|
+
{ id: 'people', label: 'People' },
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
/** The areas of the back office, as Access lists them, by section alias. */
|
|
16
|
+
export const AREAS = [
|
|
17
|
+
{ section: 'Umb.Section.Content', label: 'Content', line: "The site's pages." },
|
|
18
|
+
{
|
|
19
|
+
section: 'Umb.Section.Library',
|
|
20
|
+
label: 'Library',
|
|
21
|
+
line: 'Shared pieces pages are built from: blocks, menus and promos.',
|
|
22
|
+
},
|
|
23
|
+
{ section: 'Umb.Section.Media', label: 'Media', line: 'Images, documents and other files.' },
|
|
24
|
+
{
|
|
25
|
+
section: 'Crombolo.Section.Forms',
|
|
26
|
+
label: 'Forms',
|
|
27
|
+
line: 'Forms visitors fill in, and their answers.',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
section: 'Umb.Section.Members',
|
|
31
|
+
label: 'Members',
|
|
32
|
+
line: 'People who sign in to the site itself.',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
section: 'Umb.Section.Settings',
|
|
36
|
+
label: 'Settings',
|
|
37
|
+
line: "Content types, templates, redirects and the site's tools.",
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
section: 'Umb.Section.Users',
|
|
41
|
+
label: 'Users',
|
|
42
|
+
line: 'The people who use the back office, and their groups.',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
section: 'Umb.Section.Translation',
|
|
46
|
+
label: 'Translation',
|
|
47
|
+
line: 'The dictionary of words templates show in each language.',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
section: 'Crombolo.Section.Workflow',
|
|
51
|
+
label: 'Workflow',
|
|
52
|
+
line: 'The approval steps a page goes through before it is published.',
|
|
53
|
+
},
|
|
54
|
+
]
|
|
55
|
+
|
|
56
|
+
const D = (verb) => `Umb.Document.${verb}`
|
|
57
|
+
const E = (verb) => `Umb.Element.${verb}`
|
|
58
|
+
|
|
59
|
+
const cumulative = (steps) => steps.map((_, i) => steps.slice(0, i + 1).flat())
|
|
60
|
+
|
|
61
|
+
/** Each kind's levels: an id, a label, a line, and its verbs, each level adding to the one before. */
|
|
62
|
+
export const LEVELS = {
|
|
63
|
+
pages: zip(
|
|
64
|
+
[
|
|
65
|
+
['none', 'None', "Can't open pages"],
|
|
66
|
+
['see', 'See', 'Read, no changes'],
|
|
67
|
+
['edit', 'Edit', 'Write and organise drafts'],
|
|
68
|
+
['publish', 'Edit and publish', 'Also publish, unpublish, roll back'],
|
|
69
|
+
['full', 'Full control', 'Also delete, protect, set hostnames'],
|
|
70
|
+
],
|
|
71
|
+
cumulative([
|
|
72
|
+
[],
|
|
73
|
+
[D('Read')],
|
|
74
|
+
[D('Create'), D('Update'), D('Move'), D('Duplicate'), D('Sort'), D('PropertyValue.Write')],
|
|
75
|
+
[D('Publish'), D('Unpublish'), D('Rollback')],
|
|
76
|
+
[
|
|
77
|
+
D('Delete'),
|
|
78
|
+
'Umb.DocumentRecycleBin.Restore',
|
|
79
|
+
D('PublicAccess'),
|
|
80
|
+
D('CultureAndHostnames'),
|
|
81
|
+
D('Permissions'),
|
|
82
|
+
],
|
|
83
|
+
]),
|
|
84
|
+
),
|
|
85
|
+
library: zip(
|
|
86
|
+
[
|
|
87
|
+
['none', 'None', "Can't open the Library"],
|
|
88
|
+
['see', 'See', 'Read, no changes'],
|
|
89
|
+
['edit', 'Edit', 'Write and organise drafts'],
|
|
90
|
+
['publish', 'Edit and publish', 'Also publish, unpublish, roll back'],
|
|
91
|
+
['full', 'Full control', 'Also delete'],
|
|
92
|
+
],
|
|
93
|
+
cumulative([
|
|
94
|
+
[],
|
|
95
|
+
[E('Read')],
|
|
96
|
+
[E('Create'), E('Update'), E('Move'), E('Duplicate')],
|
|
97
|
+
[E('Publish'), E('Unpublish'), E('Rollback')],
|
|
98
|
+
[E('Delete')],
|
|
99
|
+
]),
|
|
100
|
+
),
|
|
101
|
+
media: zip(
|
|
102
|
+
[
|
|
103
|
+
['none', 'None', "Can't open media"],
|
|
104
|
+
['see', 'See', 'Look, no changes'],
|
|
105
|
+
['edit', 'Upload and edit', 'Add, change and remove files'],
|
|
106
|
+
],
|
|
107
|
+
cumulative([[], ['Crombolo.Media.Read'], ['Crombolo.Media.Update']]),
|
|
108
|
+
),
|
|
109
|
+
forms: zip(
|
|
110
|
+
[
|
|
111
|
+
['none', 'None', "Can't open forms"],
|
|
112
|
+
['see', 'See forms and answers', 'Read, no changes'],
|
|
113
|
+
['manage', 'Manage forms', 'Design forms, change and delete answers'],
|
|
114
|
+
],
|
|
115
|
+
cumulative([
|
|
116
|
+
[],
|
|
117
|
+
['Crombolo.Form.Read', 'Crombolo.FormEntry.Read'],
|
|
118
|
+
['Crombolo.Form.Manage', 'Crombolo.FormEntry.Manage'],
|
|
119
|
+
]),
|
|
120
|
+
),
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function zip(words, verbs) {
|
|
124
|
+
return words.map(([id, label, line], i) => ({ id, label, line, verbs: verbs[i] }))
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** Forms' sensitive answers: a toggle beside the level. */
|
|
128
|
+
export const SENSITIVE_ANSWERS = 'Crombolo.FormEntry.Sensitive'
|
|
129
|
+
|
|
130
|
+
/** Which area each kind belongs to, for "Access is off". */
|
|
131
|
+
export const KIND_AREA = {
|
|
132
|
+
pages: 'Umb.Section.Content',
|
|
133
|
+
library: 'Umb.Section.Library',
|
|
134
|
+
media: 'Umb.Section.Media',
|
|
135
|
+
forms: 'Crombolo.Section.Forms',
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export const KIND_LABEL = { pages: 'Pages', library: 'Library', media: 'Media', forms: 'Forms' }
|
|
139
|
+
|
|
140
|
+
/** Every verb a kind's levels speak for. */
|
|
141
|
+
export const kindVerbs = (kind) => LEVELS[kind].at(-1).verbs
|
|
142
|
+
|
|
143
|
+
/** The level a group's verbs are for one kind, or 'custom'. */
|
|
144
|
+
export function levelOf(kind, verbs) {
|
|
145
|
+
const own = new Set(kindVerbs(kind))
|
|
146
|
+
const held = new Set(verbs.filter((verb) => own.has(verb)))
|
|
147
|
+
const found = LEVELS[kind].find(
|
|
148
|
+
(level) => level.verbs.length === held.size && level.verbs.every((verb) => held.has(verb)),
|
|
149
|
+
)
|
|
150
|
+
return found ? found.id : 'custom'
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** A group's verbs with one kind set to a level; nothing else touched. */
|
|
154
|
+
export function withLevel(verbs, kind, levelId) {
|
|
155
|
+
const own = new Set(kindVerbs(kind))
|
|
156
|
+
const level = LEVELS[kind].find((l) => l.id === levelId)
|
|
157
|
+
if (!level) throw new Error(`${kind} has no level "${levelId}"`)
|
|
158
|
+
return [...new Set([...verbs.filter((verb) => !own.has(verb)), ...level.verbs])]
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** A group's verbs with one verb turned on or off, for Customise. */
|
|
162
|
+
export const withVerb = (verbs, verb, on) =>
|
|
163
|
+
on ? [...new Set([...verbs, verb])] : verbs.filter((v) => v !== verb)
|
|
164
|
+
|
|
165
|
+
/** Whether the Library follows Pages: the same level, translated. */
|
|
166
|
+
export function libraryFollowsPages(verbs) {
|
|
167
|
+
const pages = levelOf('pages', verbs)
|
|
168
|
+
return pages !== 'custom' && levelOf('library', verbs) === pages
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** What Customise shows for each verb, in plain words. */
|
|
172
|
+
export const VERB_WORDS = {
|
|
173
|
+
[D('Read')]: 'See pages',
|
|
174
|
+
[D('Create')]: 'Create pages and blueprints',
|
|
175
|
+
[D('Update')]: 'Change pages',
|
|
176
|
+
[D('Move')]: 'Move pages',
|
|
177
|
+
[D('Duplicate')]: 'Copy pages',
|
|
178
|
+
[D('Sort')]: 'Reorder pages',
|
|
179
|
+
[D('PropertyValue.Write')]: 'Change any field',
|
|
180
|
+
[D('Publish')]: 'Publish pages',
|
|
181
|
+
[D('Unpublish')]: 'Unpublish pages',
|
|
182
|
+
[D('Rollback')]: 'Roll back to an earlier version',
|
|
183
|
+
[D('Delete')]: 'Delete pages',
|
|
184
|
+
'Umb.DocumentRecycleBin.Restore': 'Restore pages from the recycle bin',
|
|
185
|
+
[D('PublicAccess')]: 'Make a page members-only',
|
|
186
|
+
[D('CultureAndHostnames')]: 'Set languages and hostnames',
|
|
187
|
+
[D('Permissions')]: 'Change who can edit a page',
|
|
188
|
+
[E('Read')]: 'See Library items',
|
|
189
|
+
[E('Create')]: 'Create Library items and folders',
|
|
190
|
+
[E('Update')]: 'Change Library items and folders',
|
|
191
|
+
[E('Move')]: 'Move Library items and folders',
|
|
192
|
+
[E('Duplicate')]: 'Copy Library items',
|
|
193
|
+
[E('Publish')]: 'Publish Library items',
|
|
194
|
+
[E('Unpublish')]: 'Unpublish Library items',
|
|
195
|
+
[E('Rollback')]: "Roll back a Library item's earlier version",
|
|
196
|
+
[E('Delete')]: 'Delete Library items and folders',
|
|
197
|
+
'Crombolo.Media.Read': 'See media',
|
|
198
|
+
'Crombolo.Media.Update': 'Upload, change and remove media',
|
|
199
|
+
'Crombolo.Form.Read': 'See forms',
|
|
200
|
+
'Crombolo.FormEntry.Read': 'Read answers',
|
|
201
|
+
'Crombolo.Form.Manage': 'Design forms',
|
|
202
|
+
'Crombolo.FormEntry.Manage': 'Change and delete answers',
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/** Data Transfer's permissions, as sentences, in order; `under` indents one beneath another. */
|
|
206
|
+
export const TRANSFER = [
|
|
207
|
+
{
|
|
208
|
+
group: 'Content',
|
|
209
|
+
verb: 'Crombolo.Remote.Pull',
|
|
210
|
+
label: "Copy this site's content to their own machine",
|
|
211
|
+
line: 'A pull: pages, media and settings, to work on locally.',
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
group: 'Content',
|
|
215
|
+
verb: 'Crombolo.Remote.PullFull',
|
|
216
|
+
under: 'Crombolo.Remote.Pull',
|
|
217
|
+
label: '…including members and users',
|
|
218
|
+
line: "People's personal data, sealed with a passphrase.",
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
group: 'Content',
|
|
222
|
+
verb: 'Crombolo.Remote.Push',
|
|
223
|
+
label: 'Send content to this site',
|
|
224
|
+
line: 'A push or a content bundle: replaces pages here with theirs.',
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
group: 'Content',
|
|
228
|
+
verb: 'Crombolo.Remote.PushProtected',
|
|
229
|
+
under: 'Crombolo.Remote.Push',
|
|
230
|
+
label: '…even when this site is protected, with nobody approving',
|
|
231
|
+
line: 'Production is usually protected.',
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
group: 'Structure and code',
|
|
235
|
+
verb: 'Crombolo.Remote.ApplyStructure',
|
|
236
|
+
label: "Change this site's structure",
|
|
237
|
+
line: 'Content types, stylesheets and scripts arriving in a bundle.',
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
group: 'Structure and code',
|
|
241
|
+
verb: 'Crombolo.Remote.InstallCode',
|
|
242
|
+
warning: true,
|
|
243
|
+
label: 'Install code on this site',
|
|
244
|
+
line: 'Templates, server code and whole-site pushes: all of these run on the server. Nobody has this unless a group gives it, administrators included. Keep it on a group of its own, such as "Deployers".',
|
|
245
|
+
},
|
|
246
|
+
]
|
|
247
|
+
|
|
248
|
+
/** Verbs the editor speaks for; anything else a group holds is an extension's, kept as it is. */
|
|
249
|
+
export const OWNED_VERBS = new Set([
|
|
250
|
+
...Object.keys(LEVELS).flatMap((kind) => kindVerbs(kind)),
|
|
251
|
+
SENSITIVE_ANSWERS,
|
|
252
|
+
...TRANSFER.map((entry) => entry.verb),
|
|
253
|
+
])
|
|
254
|
+
|
|
255
|
+
const levelLabel = (kind, id) => LEVELS[kind].find((level) => level.id === id)?.label ?? 'Custom'
|
|
256
|
+
|
|
257
|
+
/** An exception as the list says it: where, and what is different there. */
|
|
258
|
+
export function exceptionSentence(exception, defaults) {
|
|
259
|
+
if (exception.kind === 'field')
|
|
260
|
+
return {
|
|
261
|
+
where: `${exception.typeName} › ${exception.fieldName}`,
|
|
262
|
+
whereNote: 'a field, on every page of that type',
|
|
263
|
+
what: exception.verbs.includes(D('PropertyValue.Write'))
|
|
264
|
+
? 'Can change it'
|
|
265
|
+
: "Can see it but can't change it",
|
|
266
|
+
}
|
|
267
|
+
const kind = exception.kind === 'library' ? 'library' : 'pages'
|
|
268
|
+
const here = levelOf(kind, exception.verbs)
|
|
269
|
+
const usual = levelOf(kind, defaults)
|
|
270
|
+
return {
|
|
271
|
+
where: exception.name,
|
|
272
|
+
whereNote: 'and everything below it',
|
|
273
|
+
what: `${KIND_LABEL[kind]}: ${levelLabel(kind, here)}${here === usual ? '' : `, instead of ${levelLabel(kind, usual)}`}`,
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/** The read-back before an exception is added. */
|
|
278
|
+
export function exceptionSummary(groupName, kind, placeName, levelId) {
|
|
279
|
+
if (kind === 'field')
|
|
280
|
+
return levelId === 'edit'
|
|
281
|
+
? `${groupName} will be able to change ${placeName}.`
|
|
282
|
+
: `${groupName} will see ${placeName} but not change it.`
|
|
283
|
+
const what = {
|
|
284
|
+
none: 'not open',
|
|
285
|
+
see: 'see, but not change,',
|
|
286
|
+
edit: 'see and change, but not publish,',
|
|
287
|
+
publish: 'see, change and publish',
|
|
288
|
+
full: 'do anything with',
|
|
289
|
+
}[levelId]
|
|
290
|
+
return `${groupName} will ${what} ${kind === 'library' ? 'Library items' : 'pages'} under ${placeName}.`
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export const ACCESS_OFF = (label) =>
|
|
294
|
+
`This group can't open ${label}. Turn it on under Access to choose what they can do with it.`
|