@crombolo/backoffice-host 0.63.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/changes-dashboard.js +94 -3
- package/plugin/ci-access-words.js +1 -1
- package/plugin/ci-access.js +1 -1
- package/plugin/email-settings-words.js +86 -0
- package/plugin/email-settings.js +249 -0
- package/plugin/group-editor-words.js +13 -0
- package/plugin/group-editor.js +43 -22
- 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 +25 -21
- package/plugin/settings-section.js +7 -87
- package/plugin/sign-in/umbraco-package.json +1 -1
- package/plugin/umbraco-package.json +41 -2
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
|
}
|
|
@@ -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; }
|
|
@@ -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,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
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Settings → E-mail (story 340): the provider the site sends through, its key
|
|
3
|
+
* and the sender. Set by the site's configuration, it is shown read-only.
|
|
4
|
+
* Administrators only; every change is audited.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { css, html, nothing } from '@umbraco-cms/backoffice/external/lit'
|
|
8
|
+
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'
|
|
9
|
+
import { umbConfirmModal } from '@umbraco-cms/backoffice/modal'
|
|
10
|
+
import { bodyOf, draftOf, fieldsFor, PROVIDERS, summaryOf } from './email-settings-words.js'
|
|
11
|
+
|
|
12
|
+
const base = () => {
|
|
13
|
+
const href = document.querySelector('base')?.getAttribute('href') ?? '/umbraco/'
|
|
14
|
+
return `${href.replace(/\/$/, '')}/crombolo/api/email`
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** The answer and its body; an outcome the server refused carries its message. */
|
|
18
|
+
async function call(path, method = 'GET', body) {
|
|
19
|
+
const response = await fetch(`${base()}${path}`, {
|
|
20
|
+
method,
|
|
21
|
+
credentials: 'include',
|
|
22
|
+
headers: {
|
|
23
|
+
accept: 'application/json',
|
|
24
|
+
...(body ? { 'content-type': 'application/json' } : {}),
|
|
25
|
+
},
|
|
26
|
+
...(body ? { body: JSON.stringify(body) } : {}),
|
|
27
|
+
})
|
|
28
|
+
const json = await response.json().catch(() => ({}))
|
|
29
|
+
if (!response.ok) throw new Error(json.message ?? `E-mail settings answered ${response.status}.`)
|
|
30
|
+
return json
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default class CromboloEmailSettingsElement extends UmbLitElement {
|
|
34
|
+
static properties = {
|
|
35
|
+
_view: { state: true },
|
|
36
|
+
_draft: { state: true },
|
|
37
|
+
_problem: { state: true },
|
|
38
|
+
_done: { state: true },
|
|
39
|
+
_busy: { state: true },
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
constructor() {
|
|
43
|
+
super()
|
|
44
|
+
this._view = undefined
|
|
45
|
+
this._draft = draftOf(undefined)
|
|
46
|
+
this._problem = ''
|
|
47
|
+
this._done = ''
|
|
48
|
+
this._busy = false
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
connectedCallback() {
|
|
52
|
+
super.connectedCallback()
|
|
53
|
+
this.#load()
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async #load() {
|
|
57
|
+
try {
|
|
58
|
+
this._view = await call('/settings')
|
|
59
|
+
this._draft = draftOf(this._view)
|
|
60
|
+
} catch (error) {
|
|
61
|
+
this._problem = error.message
|
|
62
|
+
this._view ??= { source: 'none', status: {} }
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async #run(work, done) {
|
|
67
|
+
this._busy = true
|
|
68
|
+
this._problem = ''
|
|
69
|
+
this._done = ''
|
|
70
|
+
try {
|
|
71
|
+
await work()
|
|
72
|
+
await this.#load()
|
|
73
|
+
this._done = done
|
|
74
|
+
} catch (error) {
|
|
75
|
+
this._problem = error.message
|
|
76
|
+
} finally {
|
|
77
|
+
this._busy = false
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
#save() {
|
|
82
|
+
return this.#run(() => call('/settings', 'PUT', bodyOf(this._draft)), 'Saved.')
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
#test() {
|
|
86
|
+
return this.#run(() => call('/test', 'POST', {}), 'A test e-mail is on its way to you.')
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
async #clear() {
|
|
90
|
+
await umbConfirmModal(this, {
|
|
91
|
+
color: 'danger',
|
|
92
|
+
headline: 'Remove the e-mail settings?',
|
|
93
|
+
content:
|
|
94
|
+
'Invitations, password resets, notifications and form e-mails stop until it is set up again.',
|
|
95
|
+
confirmLabel: 'Remove',
|
|
96
|
+
})
|
|
97
|
+
await this.#run(() => call('/settings', 'DELETE'), 'Removed.')
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
#input(name, label, options = {}) {
|
|
101
|
+
return html`<uui-form-layout-item>
|
|
102
|
+
<uui-label slot="label" for=${name}>${label}</uui-label>
|
|
103
|
+
<uui-input
|
|
104
|
+
id=${name}
|
|
105
|
+
label=${label}
|
|
106
|
+
type=${options.type ?? 'text'}
|
|
107
|
+
placeholder=${options.placeholder ?? ''}
|
|
108
|
+
?readonly=${options.readonly}
|
|
109
|
+
.value=${this._draft[name] ?? ''}
|
|
110
|
+
@input=${(event) => (this._draft = { ...this._draft, [name]: event.target.value })}></uui-input>
|
|
111
|
+
${options.hint ? html`<div slot="description">${options.hint}</div>` : nothing}
|
|
112
|
+
</uui-form-layout-item>`
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
#form() {
|
|
116
|
+
const view = this._view
|
|
117
|
+
const locked = view.source === 'config' || view.source === 'off'
|
|
118
|
+
if (view.source === 'off') return nothing
|
|
119
|
+
const draft = this._draft
|
|
120
|
+
const provider = PROVIDERS[draft.provider]
|
|
121
|
+
const keyHint = locked
|
|
122
|
+
? undefined
|
|
123
|
+
: !view.canKeepKeys
|
|
124
|
+
? "This site can't keep keys until whoever hosts it gives it a secret key."
|
|
125
|
+
: view.keyKept
|
|
126
|
+
? 'A key is kept. Leave this empty to keep it.'
|
|
127
|
+
: undefined
|
|
128
|
+
return html`<div class="form">
|
|
129
|
+
<uui-form-layout-item>
|
|
130
|
+
<uui-label slot="label" for="provider">Provider</uui-label>
|
|
131
|
+
<uui-select
|
|
132
|
+
id="provider"
|
|
133
|
+
label="Provider"
|
|
134
|
+
?disabled=${locked}
|
|
135
|
+
.options=${Object.entries(PROVIDERS).map(([value, { label }]) => ({
|
|
136
|
+
name: label,
|
|
137
|
+
value,
|
|
138
|
+
selected: draft.provider === value,
|
|
139
|
+
}))}
|
|
140
|
+
@change=${(event) => (this._draft = { ...this._draft, provider: event.target.value })}></uui-select>
|
|
141
|
+
</uui-form-layout-item>
|
|
142
|
+
${this.#input('from', 'Send from', { placeholder: 'no-reply@example.com', readonly: locked })}
|
|
143
|
+
${this.#input('fromName', 'Sender name (optional)', { placeholder: 'Example', readonly: locked })}
|
|
144
|
+
${fieldsFor(draft.provider).map((field) =>
|
|
145
|
+
this.#input(field.name, field.label, { placeholder: field.placeholder, readonly: locked }),
|
|
146
|
+
)}
|
|
147
|
+
${
|
|
148
|
+
locked
|
|
149
|
+
? nothing
|
|
150
|
+
: this.#input('key', provider?.key ?? 'Key', {
|
|
151
|
+
type: 'password',
|
|
152
|
+
hint: keyHint,
|
|
153
|
+
placeholder: view.keyKept ? '••••••••' : '',
|
|
154
|
+
})
|
|
155
|
+
}
|
|
156
|
+
<div class="actions">
|
|
157
|
+
${
|
|
158
|
+
locked
|
|
159
|
+
? nothing
|
|
160
|
+
: html`<uui-button look="primary" label="Save" ?disabled=${this._busy} @click=${() => this.#save()}></uui-button>`
|
|
161
|
+
}
|
|
162
|
+
<uui-button
|
|
163
|
+
look="secondary"
|
|
164
|
+
label="Send me a test e-mail"
|
|
165
|
+
?disabled=${this._busy || !view.status?.available}
|
|
166
|
+
@click=${() => this.#test()}></uui-button>
|
|
167
|
+
${
|
|
168
|
+
view.source === 'settings'
|
|
169
|
+
? html`<uui-button
|
|
170
|
+
look="secondary"
|
|
171
|
+
color="danger"
|
|
172
|
+
label="Remove"
|
|
173
|
+
?disabled=${this._busy}
|
|
174
|
+
@click=${() => this.#clear()}></uui-button>`
|
|
175
|
+
: nothing
|
|
176
|
+
}
|
|
177
|
+
</div>
|
|
178
|
+
</div>`
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
render() {
|
|
182
|
+
const view = this._view
|
|
183
|
+
if (!view) return html`<uui-loader></uui-loader>`
|
|
184
|
+
const locked = view.source === 'config' || view.source === 'off'
|
|
185
|
+
const affects = view.status?.affects ?? []
|
|
186
|
+
return html`<uui-box headline="E-mail">
|
|
187
|
+
<p class=${view.status?.available ? 'summary' : 'summary warning'}>
|
|
188
|
+
${view.status?.available ? nothing : html`<uui-icon name="icon-alert"></uui-icon>`}
|
|
189
|
+
${summaryOf(view)}
|
|
190
|
+
</p>
|
|
191
|
+
${
|
|
192
|
+
affects.length > 0
|
|
193
|
+
? html`<p>Until it is, these are unavailable:</p>
|
|
194
|
+
<ul class="affected">
|
|
195
|
+
${affects.map((feature) => html`<li>${feature}</li>`)}
|
|
196
|
+
</ul>`
|
|
197
|
+
: nothing
|
|
198
|
+
}
|
|
199
|
+
${locked ? html`<p class="note">Whoever hosts the site changes it in the server's configuration.</p>` : nothing}
|
|
200
|
+
${this._problem ? html`<p class="problem" role="alert">${this._problem}</p>` : nothing}
|
|
201
|
+
${this._done ? html`<p class="done" role="status">${this._done}</p>` : nothing}
|
|
202
|
+
${this.#form()}
|
|
203
|
+
</uui-box>`
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
static styles = css`
|
|
207
|
+
:host {
|
|
208
|
+
display: block;
|
|
209
|
+
padding: var(--uui-size-layout-1);
|
|
210
|
+
max-width: 72rem;
|
|
211
|
+
}
|
|
212
|
+
.summary {
|
|
213
|
+
display: flex;
|
|
214
|
+
align-items: center;
|
|
215
|
+
gap: var(--uui-size-space-2);
|
|
216
|
+
margin-top: 0;
|
|
217
|
+
font-weight: 600;
|
|
218
|
+
}
|
|
219
|
+
.warning uui-icon {
|
|
220
|
+
color: var(--uui-color-warning-standalone);
|
|
221
|
+
}
|
|
222
|
+
.note {
|
|
223
|
+
color: var(--uui-color-text-alt);
|
|
224
|
+
}
|
|
225
|
+
.affected {
|
|
226
|
+
margin-top: 0;
|
|
227
|
+
}
|
|
228
|
+
.form {
|
|
229
|
+
max-width: 40rem;
|
|
230
|
+
}
|
|
231
|
+
uui-input,
|
|
232
|
+
uui-select {
|
|
233
|
+
width: 100%;
|
|
234
|
+
}
|
|
235
|
+
.actions {
|
|
236
|
+
display: flex;
|
|
237
|
+
gap: var(--uui-size-space-2);
|
|
238
|
+
margin-top: var(--uui-size-space-5);
|
|
239
|
+
}
|
|
240
|
+
.problem {
|
|
241
|
+
color: var(--uui-color-danger);
|
|
242
|
+
}
|
|
243
|
+
.done {
|
|
244
|
+
color: var(--uui-color-positive);
|
|
245
|
+
}
|
|
246
|
+
`
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
customElements.define('crombolo-email-settings', CromboloEmailSettingsElement)
|
|
@@ -290,5 +290,18 @@ export function exceptionSummary(groupName, kind, placeName, levelId) {
|
|
|
290
290
|
return `${groupName} will ${what} ${kind === 'library' ? 'Library items' : 'pages'} under ${placeName}.`
|
|
291
291
|
}
|
|
292
292
|
|
|
293
|
+
/** The site's built-in groups, whose permissions the editor shows but never changes. */
|
|
294
|
+
export const SYSTEM_GROUPS = new Set(['admin', 'sensitiveData', 'translator'])
|
|
295
|
+
|
|
296
|
+
/** Why a built-in group's access and permissions can't be changed here. */
|
|
297
|
+
export const systemGroupNote = (alias) =>
|
|
298
|
+
alias.toLowerCase() === 'admin'
|
|
299
|
+
? 'This is a system group - settings are locked'
|
|
300
|
+
: "This is one of the site's built-in groups, so its access and permissions can't be changed here."
|
|
301
|
+
|
|
302
|
+
/** What a level shows for a group: an administrator's is always the top one, as they can do everything. */
|
|
303
|
+
export const shownLevel = (kind, verbs, alias) =>
|
|
304
|
+
(alias ?? '').toLowerCase() === 'admin' ? LEVELS[kind].at(-1).id : levelOf(kind, verbs)
|
|
305
|
+
|
|
293
306
|
export const ACCESS_OFF = (label) =>
|
|
294
307
|
`This group can't open ${label}. Turn it on under Access to choose what they can do with it.`
|