@crombolo/backoffice-host 0.62.0 → 0.64.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/changes-dashboard.js +94 -3
- package/plugin/ci-access-words.js +4 -4
- package/plugin/ci-access.js +1 -1
- package/plugin/content-settings-dashboard.js +69 -0
- package/plugin/email-settings-words.js +86 -0
- package/plugin/email-settings.js +249 -0
- package/plugin/group-editor-words.js +307 -0
- package/plugin/group-editor.js +750 -0
- package/plugin/localizations/umbraco-package.json +1 -1
- package/plugin/overview-dashboard.js +11 -3
- package/plugin/overview-format.js +13 -0
- package/plugin/schema-transfer-client.js +40 -0
- package/plugin/schema-transfer-words.js +50 -0
- package/plugin/schema-transfer.js +166 -0
- package/plugin/seo/umbraco-package.json +1 -1
- package/plugin/settings-card.js +16 -2
- package/plugin/settings-cards.js +38 -37
- package/plugin/settings-section.js +7 -87
- package/plugin/sign-in/umbraco-package.json +1 -1
- package/plugin/umbraco-package.json +79 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crombolo/backoffice-host",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.64.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.64.0",
|
|
36
|
+
"@crombolo/backoffice-dist": "0.64.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."
|
|
@@ -13,15 +13,26 @@
|
|
|
13
13
|
* A content bundle waiting to be imported can be answered and imported here,
|
|
14
14
|
* by those allowed to install packages: each finding offers the answers its
|
|
15
15
|
* kind allows, and the import runs once nothing is outstanding.
|
|
16
|
+
*
|
|
17
|
+
* A schema uploaded in Settings → Schema (story 342) waits here too, with the
|
|
18
|
+
* files it brings, until an administrator applies or discards it.
|
|
16
19
|
*/
|
|
17
20
|
import { css, html, nothing } from '@umbraco-cms/backoffice/external/lit'
|
|
18
21
|
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'
|
|
19
22
|
import { downloadFile } from './download.js'
|
|
20
23
|
import { answersUrl, fetchReport, transferAction } from './report-client.js'
|
|
24
|
+
import { applyImport, discardImport } from './schema-transfer-client.js'
|
|
25
|
+
import { describeFile, describeImport } from './schema-transfer-words.js'
|
|
21
26
|
|
|
22
27
|
const KIND_LABEL = { blocking: 'Blocking', person: 'Needs a person', auto: 'Automatic' }
|
|
23
28
|
const KIND_COLOR = { blocking: 'danger', person: 'warning', auto: 'positive' }
|
|
24
|
-
const SOURCE_LABEL = {
|
|
29
|
+
const SOURCE_LABEL = {
|
|
30
|
+
upgrade: 'Schema and upgrade',
|
|
31
|
+
transfer: 'Content transfer',
|
|
32
|
+
import: 'Schema import',
|
|
33
|
+
}
|
|
34
|
+
/** What each row came from, in a word. */
|
|
35
|
+
const ROW_SOURCE = { upgrade: 'Upgrade', transfer: 'Bundle', import: 'Import' }
|
|
25
36
|
const CHOICE_LABEL = {
|
|
26
37
|
'take-bundle': 'Use the incoming version',
|
|
27
38
|
'keep-local': 'Keep this site’s version',
|
|
@@ -40,6 +51,7 @@ export default class CromboloChangesDashboardElement extends UmbLitElement {
|
|
|
40
51
|
_showResolved: { state: true },
|
|
41
52
|
_busy: { state: true },
|
|
42
53
|
_outcome: { state: true },
|
|
54
|
+
_schemaOutcome: { state: true },
|
|
43
55
|
_backupTaken: { state: true },
|
|
44
56
|
_passphrase: { state: true },
|
|
45
57
|
}
|
|
@@ -87,8 +99,29 @@ export default class CromboloChangesDashboardElement extends UmbLitElement {
|
|
|
87
99
|
}
|
|
88
100
|
}
|
|
89
101
|
|
|
90
|
-
#
|
|
102
|
+
async #schemaImport(action) {
|
|
103
|
+
this._busy = 'schema-import'
|
|
104
|
+
try {
|
|
105
|
+
const result = action === 'apply' ? await applyImport() : await discardImport()
|
|
106
|
+
this._schemaOutcome = result.ok
|
|
107
|
+
? {
|
|
108
|
+
ok: true,
|
|
109
|
+
message:
|
|
110
|
+
action === 'apply'
|
|
111
|
+
? 'The schema import was applied.'
|
|
112
|
+
: 'The schema import was discarded.',
|
|
113
|
+
}
|
|
114
|
+
: result
|
|
115
|
+
} finally {
|
|
116
|
+
this._busy = undefined
|
|
117
|
+
await this.#load()
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
#group(findings, transfers = [], schemaImport = null) {
|
|
91
122
|
const groups = new Map()
|
|
123
|
+
if (schemaImport)
|
|
124
|
+
groups.set('import|schema', { source: 'import', scope: 'schema', findings: [] })
|
|
92
125
|
// A bundle with nothing to answer is still waiting to be imported.
|
|
93
126
|
for (const pending of transfers)
|
|
94
127
|
groups.set(`transfer|${pending.bundleId}`, {
|
|
@@ -111,7 +144,7 @@ export default class CromboloChangesDashboardElement extends UmbLitElement {
|
|
|
111
144
|
if (!this._report) return html`<uui-box headline="Changes"><uui-loader></uui-loader></uui-box>`
|
|
112
145
|
const { health, findings, counts, bundles = [], upgrades, transfers = [] } = this._report
|
|
113
146
|
const shown = findings.filter((f) => this._showResolved || f.status === 'open')
|
|
114
|
-
const groups = this.#group(shown, transfers)
|
|
147
|
+
const groups = this.#group(shown, transfers, this._report.schemaImport)
|
|
115
148
|
return html`
|
|
116
149
|
<uui-box headline="Changes">
|
|
117
150
|
<p>
|
|
@@ -142,6 +175,11 @@ export default class CromboloChangesDashboardElement extends UmbLitElement {
|
|
|
142
175
|
@change=${(e) => (this._showResolved = e.target.checked)}
|
|
143
176
|
></uui-toggle>
|
|
144
177
|
</div>
|
|
178
|
+
${
|
|
179
|
+
this._schemaOutcome
|
|
180
|
+
? html`<p class=${this._schemaOutcome.ok ? 'done' : 'problem'} role="status">${this._schemaOutcome.message}</p>`
|
|
181
|
+
: nothing
|
|
182
|
+
}
|
|
145
183
|
${
|
|
146
184
|
groups.length === 0
|
|
147
185
|
? html`<p class="empty">Nothing outstanding. <code>crombolo upgrade check</code> and <code>crombolo content check</code> write findings here.</p>`
|
|
@@ -219,6 +257,7 @@ export default class CromboloChangesDashboardElement extends UmbLitElement {
|
|
|
219
257
|
? nothing
|
|
220
258
|
: html`<uui-table>
|
|
221
259
|
<uui-table-head>
|
|
260
|
+
<uui-table-head-cell>Source</uui-table-head-cell>
|
|
222
261
|
<uui-table-head-cell>Kind</uui-table-head-cell>
|
|
223
262
|
<uui-table-head-cell>What</uui-table-head-cell>
|
|
224
263
|
<uui-table-head-cell>Where</uui-table-head-cell>
|
|
@@ -226,6 +265,7 @@ export default class CromboloChangesDashboardElement extends UmbLitElement {
|
|
|
226
265
|
</uui-table-head>
|
|
227
266
|
${group.findings.map(
|
|
228
267
|
(f) => html`<uui-table-row class=${f.status}>
|
|
268
|
+
<uui-table-cell><uui-tag look="secondary">${ROW_SOURCE[group.source] ?? group.source}</uui-tag></uui-table-cell>
|
|
229
269
|
<uui-table-cell><uui-tag color=${KIND_COLOR[f.kind]}>${KIND_LABEL[f.kind]}</uui-tag></uui-table-cell>
|
|
230
270
|
<uui-table-cell>${f.message}</uui-table-cell>
|
|
231
271
|
<uui-table-cell>
|
|
@@ -239,6 +279,55 @@ export default class CromboloChangesDashboardElement extends UmbLitElement {
|
|
|
239
279
|
</uui-table>`
|
|
240
280
|
}
|
|
241
281
|
${answering ? this.#renderPending(pending, group.findings) : nothing}
|
|
282
|
+
${group.source === 'import' ? this.#renderSchemaImport() : nothing}
|
|
283
|
+
`
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
#renderSchemaImport() {
|
|
287
|
+
const waiting = this._report.schemaImport
|
|
288
|
+
if (!waiting) return nothing
|
|
289
|
+
const files = [
|
|
290
|
+
...waiting.added.map((path) => ({ path, change: 'New' })),
|
|
291
|
+
...waiting.changed.map((path) => ({ path, change: 'Changed' })),
|
|
292
|
+
]
|
|
293
|
+
return html`
|
|
294
|
+
<p>
|
|
295
|
+
<strong>${waiting.fileName}</strong>, uploaded by ${waiting.uploadedBy}
|
|
296
|
+
${waiting.uploadedAt?.slice(0, 10) ?? ''}, brings ${describeImport(waiting)}.
|
|
297
|
+
${waiting.blocked ? 'Something above stops it from being applied.' : 'Nothing changes until it is applied.'}
|
|
298
|
+
</p>
|
|
299
|
+
<uui-table>
|
|
300
|
+
<uui-table-head>
|
|
301
|
+
<uui-table-head-cell>Change</uui-table-head-cell>
|
|
302
|
+
<uui-table-head-cell>What</uui-table-head-cell>
|
|
303
|
+
<uui-table-head-cell>Name</uui-table-head-cell>
|
|
304
|
+
</uui-table-head>
|
|
305
|
+
${files.map(({ path, change }) => {
|
|
306
|
+
const { kind, name } = describeFile(path)
|
|
307
|
+
return html`<uui-table-row>
|
|
308
|
+
<uui-table-cell><uui-tag look="secondary">${change}</uui-tag></uui-table-cell>
|
|
309
|
+
<uui-table-cell>${kind}</uui-table-cell>
|
|
310
|
+
<uui-table-cell>${name}</uui-table-cell>
|
|
311
|
+
</uui-table-row>`
|
|
312
|
+
})}
|
|
313
|
+
</uui-table>
|
|
314
|
+
${
|
|
315
|
+
this._report.mayApplySchema
|
|
316
|
+
? html`<div class="actions">
|
|
317
|
+
<uui-button
|
|
318
|
+
look="primary"
|
|
319
|
+
label="Apply"
|
|
320
|
+
?disabled=${waiting.blocked || this._busy === 'schema-import'}
|
|
321
|
+
@click=${() => this.#schemaImport('apply')}></uui-button>
|
|
322
|
+
<uui-button
|
|
323
|
+
look="secondary"
|
|
324
|
+
color="danger"
|
|
325
|
+
label="Discard"
|
|
326
|
+
?disabled=${this._busy === 'schema-import'}
|
|
327
|
+
@click=${() => this.#schemaImport('discard')}></uui-button>
|
|
328
|
+
</div>`
|
|
329
|
+
: nothing
|
|
330
|
+
}
|
|
242
331
|
`
|
|
243
332
|
}
|
|
244
333
|
|
|
@@ -410,6 +499,8 @@ export default class CromboloChangesDashboardElement extends UmbLitElement {
|
|
|
410
499
|
small { margin-left: var(--uui-size-space-2); }
|
|
411
500
|
.empty { color: var(--uui-color-text-alt); }
|
|
412
501
|
.choices, .actions { display: flex; flex-wrap: wrap; gap: var(--uui-size-space-2); }
|
|
502
|
+
.done { color: var(--uui-color-positive); }
|
|
503
|
+
.problem { color: var(--uui-color-danger); }
|
|
413
504
|
.pending { margin: var(--uui-size-space-3) 0 var(--uui-size-space-5); }
|
|
414
505
|
.pending ul { margin: 0 0 var(--uui-size-space-3); padding-left: var(--uui-size-space-5); }
|
|
415
506
|
.state { display: flex; gap: var(--uui-size-space-3); align-items: center; }
|
|
@@ -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
|
|
|
@@ -55,7 +55,7 @@ export async function trustApi(method, path = '', body) {
|
|
|
55
55
|
if (response.status === 204) return undefined
|
|
56
56
|
const result = await response.json().catch(() => ({}))
|
|
57
57
|
if (!response.ok) {
|
|
58
|
-
const error = new Error(result.title ?? `
|
|
58
|
+
const error = new Error(result.title ?? `Deployment pipelines responded ${response.status}`)
|
|
59
59
|
error.items = result.items
|
|
60
60
|
throw error
|
|
61
61
|
}
|
package/plugin/ci-access.js
CHANGED
|
@@ -146,7 +146,7 @@ export default class CromboloCiAccessElement extends UmbLitElement {
|
|
|
146
146
|
const state = this._state
|
|
147
147
|
if (!state) return html`<uui-loader></uui-loader>`
|
|
148
148
|
if (state.error)
|
|
149
|
-
return html`<uui-box headline="
|
|
149
|
+
return html`<uui-box headline="Deployment pipelines"><p role="alert">${state.error}</p></uui-box>`
|
|
150
150
|
return html`
|
|
151
151
|
${
|
|
152
152
|
state.remoteEnabled
|
|
@@ -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
|
+
)
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The words and fields of Settings → E-mail (story 340). Pure, so the unit
|
|
3
|
+
* tests read it outside a browser.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export const PROVIDERS = {
|
|
7
|
+
resend: { label: 'Resend', key: 'API key' },
|
|
8
|
+
postmark: { label: 'Postmark', key: 'Server token' },
|
|
9
|
+
ses: { label: 'Amazon SES', key: 'Secret access key' },
|
|
10
|
+
custom: { label: 'Your own endpoint', key: 'Bearer token (optional)' },
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** The fields a provider asks for, beyond the sender and its key, in order. */
|
|
14
|
+
export function fieldsFor(provider) {
|
|
15
|
+
if (provider === 'ses')
|
|
16
|
+
return [
|
|
17
|
+
{ name: 'sesRegion', label: 'Region', placeholder: 'ap-southeast-2' },
|
|
18
|
+
{ name: 'sesAccessKeyId', label: 'Access key ID' },
|
|
19
|
+
]
|
|
20
|
+
if (provider === 'custom')
|
|
21
|
+
return [{ name: 'url', label: 'Send to', placeholder: 'https://mail.example.com/send' }]
|
|
22
|
+
if (provider === 'postmark')
|
|
23
|
+
return [{ name: 'postmarkStream', label: 'Message stream (optional)', placeholder: 'outbound' }]
|
|
24
|
+
return []
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const FIELDS = [
|
|
28
|
+
'provider',
|
|
29
|
+
'from',
|
|
30
|
+
'fromName',
|
|
31
|
+
'url',
|
|
32
|
+
'postmarkStream',
|
|
33
|
+
'sesRegion',
|
|
34
|
+
'sesAccessKeyId',
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The form's starting values, from what the server says is set.
|
|
39
|
+
*
|
|
40
|
+
* @param {Record<string, any> | undefined} view
|
|
41
|
+
* @returns {Record<string, string>}
|
|
42
|
+
*/
|
|
43
|
+
export function draftOf(view) {
|
|
44
|
+
/** @type {Record<string, string>} */
|
|
45
|
+
const draft = { key: '' }
|
|
46
|
+
for (const name of FIELDS) draft[name] = view?.[name] ?? ''
|
|
47
|
+
if (!PROVIDERS[draft.provider]) draft.provider = 'resend'
|
|
48
|
+
return draft
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* What is sent to save the form: the provider's own fields, and a key only when one was typed.
|
|
53
|
+
*
|
|
54
|
+
* @param {Record<string, string>} draft
|
|
55
|
+
* @returns {Record<string, string>}
|
|
56
|
+
*/
|
|
57
|
+
export function bodyOf(draft) {
|
|
58
|
+
const own = new Set(fieldsFor(draft.provider).map((field) => field.name))
|
|
59
|
+
/** @type {Record<string, string>} */
|
|
60
|
+
const body = {
|
|
61
|
+
provider: draft.provider,
|
|
62
|
+
from: draft.from.trim(),
|
|
63
|
+
fromName: draft.fromName.trim(),
|
|
64
|
+
}
|
|
65
|
+
for (const name of own) if (draft[name]?.trim()) body[name] = draft[name].trim()
|
|
66
|
+
if (draft.key.trim()) body.key = draft.key.trim()
|
|
67
|
+
return body
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** One sentence on where e-mail stands, for the top of the page. */
|
|
71
|
+
export function summaryOf(view) {
|
|
72
|
+
if (!view) return ''
|
|
73
|
+
if (view.source === 'off') return "E-mail is turned off by the site's configuration."
|
|
74
|
+
const name = PROVIDERS[view.provider]?.label ?? view.provider
|
|
75
|
+
if (view.source === 'config')
|
|
76
|
+
return view.status?.available
|
|
77
|
+
? `E-mail is sent through ${name}, set by the site's configuration.`
|
|
78
|
+
: "E-mail is set by the site's configuration, but can't be sent. The server's log says why."
|
|
79
|
+
if (view.status?.available) return `E-mail is sent through ${name}.`
|
|
80
|
+
if (view.status?.provider === 'log')
|
|
81
|
+
return "E-mail is written to the server's log, not sent, until a provider is set up."
|
|
82
|
+
return 'E-mail is not set up, so nothing can be sent.'
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Whether the E-mail card on the Settings page carries a warning. */
|
|
86
|
+
export const needsAttention = (status) => Boolean(status) && !status.available
|