@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/plugin/group-editor.js
CHANGED
|
@@ -23,6 +23,9 @@ import {
|
|
|
23
23
|
levelOf,
|
|
24
24
|
libraryFollowsPages,
|
|
25
25
|
SENSITIVE_ANSWERS,
|
|
26
|
+
SYSTEM_GROUPS,
|
|
27
|
+
shownLevel,
|
|
28
|
+
systemGroupNote,
|
|
26
29
|
TABS,
|
|
27
30
|
TRANSFER,
|
|
28
31
|
VERB_WORDS,
|
|
@@ -124,6 +127,22 @@ export default class CromboloGroupEditorElement extends UmbLitElement {
|
|
|
124
127
|
#set(key, value) {
|
|
125
128
|
this.#context?.updateProperty(key, value)
|
|
126
129
|
}
|
|
130
|
+
get #alias() {
|
|
131
|
+
return this._group.alias ?? ''
|
|
132
|
+
}
|
|
133
|
+
get #isAdminGroup() {
|
|
134
|
+
return this.#alias.toLowerCase() === 'admin'
|
|
135
|
+
}
|
|
136
|
+
/** Story 338: a built-in group's access and permissions are shown, never changed. */
|
|
137
|
+
get #permissionsLocked() {
|
|
138
|
+
return this._readOnly || SYSTEM_GROUPS.has(this.#alias)
|
|
139
|
+
}
|
|
140
|
+
#renderSystemNote() {
|
|
141
|
+
return SYSTEM_GROUPS.has(this.#alias)
|
|
142
|
+
? html`<div class="notice" role="status"><uui-icon name="icon-lock"></uui-icon>${systemGroupNote(this.#alias)}</div>`
|
|
143
|
+
: nothing
|
|
144
|
+
}
|
|
145
|
+
|
|
127
146
|
#hasArea(section) {
|
|
128
147
|
return (this._group.sections ?? []).includes(section)
|
|
129
148
|
}
|
|
@@ -174,7 +193,7 @@ export default class CromboloGroupEditorElement extends UmbLitElement {
|
|
|
174
193
|
class="switch ${on ? 'on' : ''}"
|
|
175
194
|
aria-checked=${on ? 'true' : 'false'}
|
|
176
195
|
aria-label=${`${label}: ${on ? 'on' : 'off'}`}
|
|
177
|
-
?disabled=${this
|
|
196
|
+
?disabled=${this.#permissionsLocked}
|
|
178
197
|
@click=${() => toggle(!on)}><span></span></button>`
|
|
179
198
|
}
|
|
180
199
|
|
|
@@ -185,7 +204,7 @@ export default class CromboloGroupEditorElement extends UmbLitElement {
|
|
|
185
204
|
<uui-toggle
|
|
186
205
|
label="Everywhere"
|
|
187
206
|
?checked=${root}
|
|
188
|
-
?
|
|
207
|
+
?disabled=${this.#permissionsLocked}
|
|
189
208
|
@change=${(e) => {
|
|
190
209
|
this.#set(rootKey, e.target.checked)
|
|
191
210
|
this.#set(nodeKey, null)
|
|
@@ -206,20 +225,20 @@ export default class CromboloGroupEditorElement extends UmbLitElement {
|
|
|
206
225
|
const g = this._group
|
|
207
226
|
if (section === 'Umb.Section.Content')
|
|
208
227
|
return html`
|
|
209
|
-
${this.#renderWhere('Pages', g.documentRootAccess, g.documentStartNode, 'documentRootAccess', 'documentStartNode', (selection) => html`<umb-input-document max="1" ?readonly=${this
|
|
228
|
+
${this.#renderWhere('Pages', g.documentRootAccess, g.documentStartNode, 'documentRootAccess', 'documentStartNode', (selection) => html`<umb-input-document max="1" ?readonly=${this.#permissionsLocked} .selection=${selection} @change=${this.#pick('documentStartNode')}></umb-input-document>`)}
|
|
210
229
|
<div class="row">
|
|
211
230
|
<span class="row-label">Languages</span>
|
|
212
231
|
<div class="row-value">
|
|
213
232
|
<uui-toggle
|
|
214
233
|
label="All languages"
|
|
215
234
|
?checked=${g.hasAccessToAllLanguages}
|
|
216
|
-
?
|
|
235
|
+
?disabled=${this.#permissionsLocked}
|
|
217
236
|
@change=${(e) => this.#set('hasAccessToAllLanguages', e.target.checked)}></uui-toggle>
|
|
218
237
|
${
|
|
219
238
|
g.hasAccessToAllLanguages
|
|
220
239
|
? nothing
|
|
221
240
|
: html`<umb-input-language
|
|
222
|
-
?readonly=${this
|
|
241
|
+
?readonly=${this.#permissionsLocked}
|
|
223
242
|
.selection=${g.languages ?? []}
|
|
224
243
|
@change=${(e) => this.#set('languages', e.target.selection)}></umb-input-language>`
|
|
225
244
|
}
|
|
@@ -234,7 +253,7 @@ export default class CromboloGroupEditorElement extends UmbLitElement {
|
|
|
234
253
|
'elementRootAccess',
|
|
235
254
|
'elementStartNode',
|
|
236
255
|
(selection) =>
|
|
237
|
-
html`<umb-input-element max="1" ?folderOnly=${true} ?readonly=${this
|
|
256
|
+
html`<umb-input-element max="1" ?folderOnly=${true} ?readonly=${this.#permissionsLocked} .selection=${selection} @change=${this.#pick('elementStartNode')}></umb-input-element>`,
|
|
238
257
|
)
|
|
239
258
|
if (section === 'Umb.Section.Media')
|
|
240
259
|
return this.#renderWhere(
|
|
@@ -244,14 +263,14 @@ export default class CromboloGroupEditorElement extends UmbLitElement {
|
|
|
244
263
|
'mediaRootAccess',
|
|
245
264
|
'mediaStartNode',
|
|
246
265
|
(selection) =>
|
|
247
|
-
html`<umb-input-media max="1" folder-filter="foldersOnly" ?readonly=${this
|
|
266
|
+
html`<umb-input-media max="1" folder-filter="foldersOnly" ?readonly=${this.#permissionsLocked} .selection=${selection} @change=${this.#pick('mediaStartNode')}></umb-input-media>`,
|
|
248
267
|
)
|
|
249
268
|
return nothing
|
|
250
269
|
}
|
|
251
270
|
|
|
252
271
|
#renderAccess() {
|
|
253
272
|
return html`
|
|
254
|
-
|
|
273
|
+
${this.#renderSystemNote()}
|
|
255
274
|
${AREAS.map((area) => {
|
|
256
275
|
const on = this.#hasArea(area.section)
|
|
257
276
|
const settings = on ? this.#renderAreaSettings(area.section) : nothing
|
|
@@ -280,7 +299,7 @@ export default class CromboloGroupEditorElement extends UmbLitElement {
|
|
|
280
299
|
type="radio"
|
|
281
300
|
name=${`level-${kind}`}
|
|
282
301
|
.checked=${current === level.id}
|
|
283
|
-
?disabled=${disabled || this
|
|
302
|
+
?disabled=${disabled || this.#permissionsLocked}
|
|
284
303
|
@change=${() => choose(level.id)} />
|
|
285
304
|
<span class="level-text"><strong>${level.label}</strong><span>${level.line}</span></span>
|
|
286
305
|
</label>`,
|
|
@@ -290,6 +309,8 @@ export default class CromboloGroupEditorElement extends UmbLitElement {
|
|
|
290
309
|
}
|
|
291
310
|
|
|
292
311
|
#renderCustomise(kind, current) {
|
|
312
|
+
// An administrator can do everything, so their verbs are nothing to customise.
|
|
313
|
+
if (this.#isAdminGroup) return nothing
|
|
293
314
|
const open = this._open[kind] || current === 'custom'
|
|
294
315
|
const verbs = this.#verbs
|
|
295
316
|
return html`<details ?open=${open} @toggle=${(e) => (this._open = { ...this._open, [kind]: e.target.open })}>
|
|
@@ -300,7 +321,7 @@ export default class CromboloGroupEditorElement extends UmbLitElement {
|
|
|
300
321
|
<input
|
|
301
322
|
type="checkbox"
|
|
302
323
|
.checked=${verbs.includes(verb)}
|
|
303
|
-
?disabled=${this
|
|
324
|
+
?disabled=${this.#permissionsLocked}
|
|
304
325
|
@change=${(e) => this.#setVerbs(withVerb(verbs, verb, e.target.checked))} />
|
|
305
326
|
${VERB_WORDS[verb] ?? verb}
|
|
306
327
|
</label>`,
|
|
@@ -322,7 +343,7 @@ export default class CromboloGroupEditorElement extends UmbLitElement {
|
|
|
322
343
|
</div>
|
|
323
344
|
${this.#renderLevels(kind, 'none', () => {}, true)}
|
|
324
345
|
</section>`
|
|
325
|
-
const current =
|
|
346
|
+
const current = shownLevel(kind, this.#verbs, this.#alias)
|
|
326
347
|
return html`<section class="kind">
|
|
327
348
|
<div class="kind-head"><h2>${label}</h2></div>
|
|
328
349
|
${this.#renderLevels(kind, current, (id) => this.#setVerbs(withLevel(this.#verbs, kind, id)))}
|
|
@@ -332,7 +353,7 @@ export default class CromboloGroupEditorElement extends UmbLitElement {
|
|
|
332
353
|
|
|
333
354
|
#renderLibrary() {
|
|
334
355
|
if (!this.#hasArea(KIND_AREA.library)) return this.#renderKind('library')
|
|
335
|
-
const follows = libraryFollowsPages(this.#verbs)
|
|
356
|
+
const follows = this.#isAdminGroup || libraryFollowsPages(this.#verbs)
|
|
336
357
|
if (!follows || this._open.libraryOwn)
|
|
337
358
|
return this.#renderKind('library', this.#renderFollow(false))
|
|
338
359
|
return html`<section class="kind">
|
|
@@ -347,7 +368,7 @@ export default class CromboloGroupEditorElement extends UmbLitElement {
|
|
|
347
368
|
type="radio"
|
|
348
369
|
name="library-follows"
|
|
349
370
|
.checked=${follows}
|
|
350
|
-
?disabled=${this
|
|
371
|
+
?disabled=${this.#permissionsLocked}
|
|
351
372
|
@change=${() => {
|
|
352
373
|
this._open = { ...this._open, libraryOwn: false }
|
|
353
374
|
const pages = levelOf('pages', this.#verbs)
|
|
@@ -357,7 +378,7 @@ export default class CromboloGroupEditorElement extends UmbLitElement {
|
|
|
357
378
|
type="radio"
|
|
358
379
|
name="library-follows"
|
|
359
380
|
.checked=${!follows}
|
|
360
|
-
?disabled=${this
|
|
381
|
+
?disabled=${this.#permissionsLocked}
|
|
361
382
|
@change=${() => (this._open = { ...this._open, libraryOwn: true })} /><strong>Choose separately</strong></label>
|
|
362
383
|
</div>`
|
|
363
384
|
}
|
|
@@ -366,13 +387,13 @@ export default class CromboloGroupEditorElement extends UmbLitElement {
|
|
|
366
387
|
const sensitive = html`<label class="verb">
|
|
367
388
|
<input
|
|
368
389
|
type="checkbox"
|
|
369
|
-
.checked=${this.#verbs.includes(SENSITIVE_ANSWERS)}
|
|
370
|
-
?disabled=${this
|
|
390
|
+
.checked=${this.#isAdminGroup || this.#verbs.includes(SENSITIVE_ANSWERS)}
|
|
391
|
+
?disabled=${this.#permissionsLocked}
|
|
371
392
|
@change=${(e) => this.#setVerbs(withVerb(this.#verbs, SENSITIVE_ANSWERS, e.target.checked))} />
|
|
372
393
|
Can see answers marked sensitive
|
|
373
394
|
</label>`
|
|
374
395
|
return html`
|
|
375
|
-
|
|
396
|
+
${this.#renderSystemNote()}
|
|
376
397
|
${this.#renderKind('pages')} ${this.#renderLibrary()} ${this.#renderKind('media')}
|
|
377
398
|
${this.#renderKind('forms', sensitive)}
|
|
378
399
|
`
|
|
@@ -411,12 +432,12 @@ export default class CromboloGroupEditorElement extends UmbLitElement {
|
|
|
411
432
|
#renderExceptions() {
|
|
412
433
|
const list = this.#exceptions
|
|
413
434
|
return html`
|
|
435
|
+
${this.#renderSystemNote()}
|
|
414
436
|
<div class="intro-row">
|
|
415
|
-
<p class="intro">Places where this group's permissions are different from the ones under Permissions. Everywhere else, the usual ones apply.</p>
|
|
416
437
|
${
|
|
417
438
|
this._readOnly
|
|
418
439
|
? nothing
|
|
419
|
-
: html`<uui-button look="primary" label="Add an exception" @click=${() => (this._adding = { kind: 'pages', level: 'see' })}></uui-button>`
|
|
440
|
+
: html`<uui-button look="primary" label="Add an exception" ?disabled=${this.#permissionsLocked} @click=${() => (this._adding = { kind: 'pages', level: 'see' })}></uui-button>`
|
|
420
441
|
}
|
|
421
442
|
</div>
|
|
422
443
|
${this._adding ? this.#renderAdding() : nothing}
|
|
@@ -432,7 +453,7 @@ export default class CromboloGroupEditorElement extends UmbLitElement {
|
|
|
432
453
|
<div>${said.what}</div>
|
|
433
454
|
</div>
|
|
434
455
|
${
|
|
435
|
-
this
|
|
456
|
+
this.#permissionsLocked
|
|
436
457
|
? nothing
|
|
437
458
|
: html`<uui-button look="secondary" color="danger" label="Remove" @click=${() => this.#remove(item.index)}></uui-button>`
|
|
438
459
|
}
|
|
@@ -573,7 +594,7 @@ export default class CromboloGroupEditorElement extends UmbLitElement {
|
|
|
573
594
|
const verbs = this.#verbs
|
|
574
595
|
const groups = [...new Set(TRANSFER.map((entry) => entry.group))]
|
|
575
596
|
return html`
|
|
576
|
-
|
|
597
|
+
${this.#renderSystemNote()}
|
|
577
598
|
${groups.map(
|
|
578
599
|
(group) => html`<uui-box headline=${group}>
|
|
579
600
|
${TRANSFER.filter((entry) => entry.group === group).map((entry) => {
|
|
@@ -582,7 +603,7 @@ export default class CromboloGroupEditorElement extends UmbLitElement {
|
|
|
582
603
|
<input
|
|
583
604
|
type="checkbox"
|
|
584
605
|
.checked=${verbs.includes(entry.verb)}
|
|
585
|
-
?disabled=${this
|
|
606
|
+
?disabled=${this.#permissionsLocked || blocked}
|
|
586
607
|
@change=${(e) => this.#setVerbs(withVerb(verbs, entry.verb, e.target.checked))} />
|
|
587
608
|
<span><strong>${entry.label}</strong><span class="muted">${entry.line}</span></span>
|
|
588
609
|
</label>`
|
|
@@ -11,7 +11,15 @@ import { css, html, nothing } from '@umbraco-cms/backoffice/external/lit'
|
|
|
11
11
|
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'
|
|
12
12
|
import { umbOpenModal } from '@umbraco-cms/backoffice/modal'
|
|
13
13
|
import { UMB_SYSINFO_MODAL, UmbSysinfoRepository } from '@umbraco-cms/backoffice/sysinfo'
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
activityLine,
|
|
16
|
+
ago,
|
|
17
|
+
avatarHue,
|
|
18
|
+
contentModeOf,
|
|
19
|
+
firstName,
|
|
20
|
+
initials,
|
|
21
|
+
STATES,
|
|
22
|
+
} from './overview-format.js'
|
|
15
23
|
|
|
16
24
|
const base = () =>
|
|
17
25
|
(document.querySelector('base')?.getAttribute('href') ?? '/umbraco/').replace(/\/$/, '')
|
|
@@ -146,8 +154,8 @@ export default class CromboloOverviewDashboardElement extends UmbLitElement {
|
|
|
146
154
|
<dl class="system">
|
|
147
155
|
<dt>Version</dt>
|
|
148
156
|
<dd>${this._server?.version ?? '…'}</dd>
|
|
149
|
-
<dt>
|
|
150
|
-
<dd>${this._server?.runtimeMode
|
|
157
|
+
<dt>Content mode</dt>
|
|
158
|
+
<dd>${contentModeOf(this._server?.runtimeMode)}</dd>
|
|
151
159
|
</dl>
|
|
152
160
|
<div class="system-links">
|
|
153
161
|
<a href="https://github.com/kineco-au/crombolo-cms" target="_blank" rel="noopener">
|
|
@@ -69,3 +69,16 @@ export function avatarHue(name) {
|
|
|
69
69
|
for (const char of String(name ?? '')) hash = (hash * 31 + char.codePointAt(0)) >>> 0
|
|
70
70
|
return hash % AVATAR_HUES
|
|
71
71
|
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The site's content mode in words (story 343), from the runtime mode the back
|
|
75
|
+
* office is told: Umbraco's `Production` when templates, stylesheets and scripts
|
|
76
|
+
* are locked, development otherwise.
|
|
77
|
+
*
|
|
78
|
+
* @param {string | undefined} runtimeMode
|
|
79
|
+
* @returns {string}
|
|
80
|
+
*/
|
|
81
|
+
export function contentModeOf(runtimeMode) {
|
|
82
|
+
if (!runtimeMode) return '…'
|
|
83
|
+
return runtimeMode === 'Production' ? 'Production' : 'Development'
|
|
84
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Settings → Schema's calls (story 342): the waiting import, an upload, and
|
|
3
|
+
* applying or discarding it. The cookie carries the session.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const base = () =>
|
|
7
|
+
`${(document.querySelector('base')?.getAttribute('href') ?? '/umbraco/').replace(/\/$/, '')}/crombolo/api/schema-transfer`
|
|
8
|
+
|
|
9
|
+
export const exportUrl = () => `${base()}/export`
|
|
10
|
+
|
|
11
|
+
async function call(path, init = {}) {
|
|
12
|
+
const response = await fetch(`${base()}${path}`, {
|
|
13
|
+
credentials: 'include',
|
|
14
|
+
...init,
|
|
15
|
+
headers: { accept: 'application/json', ...(init.headers ?? {}) },
|
|
16
|
+
})
|
|
17
|
+
const body = await response.json().catch(() => ({}))
|
|
18
|
+
if (!response.ok)
|
|
19
|
+
return {
|
|
20
|
+
ok: false,
|
|
21
|
+
message: body.message ?? `The schema import answered ${response.status}.`,
|
|
22
|
+
problems: body.problems ?? [],
|
|
23
|
+
}
|
|
24
|
+
return { ok: true, ...body }
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** The import waiting for approval, if any, and whether this site takes imports. */
|
|
28
|
+
export const fetchPending = () => call('/import')
|
|
29
|
+
|
|
30
|
+
/** Sends a file to be checked and held for approval. */
|
|
31
|
+
export const uploadSchema = (file) =>
|
|
32
|
+
call(`/import?name=${encodeURIComponent(file.name)}`, {
|
|
33
|
+
method: 'POST',
|
|
34
|
+
headers: { 'content-type': 'application/octet-stream' },
|
|
35
|
+
body: file,
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
export const applyImport = () => call('/import/apply', { method: 'POST' })
|
|
39
|
+
|
|
40
|
+
export const discardImport = () => call('/import', { method: 'DELETE' })
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The words of Settings → Schema and of a schema import waiting on the Changes
|
|
3
|
+
* dashboard (story 342). Pure, so the unit tests read it outside a browser.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const plural = (count, one, many) => `${count} ${count === 1 ? one : many}`
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* What an import brings, in a phrase: "2 new files and 1 changed file".
|
|
10
|
+
*
|
|
11
|
+
* @param {{ added?: string[], changed?: string[] }} change
|
|
12
|
+
* @returns {string}
|
|
13
|
+
*/
|
|
14
|
+
export function describeImport({ added = [], changed = [] }) {
|
|
15
|
+
const parts = []
|
|
16
|
+
if (added.length > 0) parts.push(plural(added.length, 'new file', 'new files'))
|
|
17
|
+
if (changed.length > 0) parts.push(plural(changed.length, 'changed file', 'changed files'))
|
|
18
|
+
return parts.join(' and ') || 'no files'
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** What a folder in the schema holds, in words, for the list of files an import brings. */
|
|
22
|
+
const FOLDER = {
|
|
23
|
+
'content-types': 'Document type',
|
|
24
|
+
'media-types': 'Media type',
|
|
25
|
+
'member-types': 'Member type',
|
|
26
|
+
'data-types': 'Data type',
|
|
27
|
+
forms: 'Form',
|
|
28
|
+
workflows: 'Approval workflow',
|
|
29
|
+
'user-groups': 'User group',
|
|
30
|
+
webhooks: 'Webhook',
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* A file an import brings, as what it is and its name.
|
|
35
|
+
*
|
|
36
|
+
* @param {string} path
|
|
37
|
+
* @returns {{ kind: string, name: string }}
|
|
38
|
+
*/
|
|
39
|
+
export function describeFile(path) {
|
|
40
|
+
const [folder = '', ...rest] = path.split('/')
|
|
41
|
+
if (rest.length === 0)
|
|
42
|
+
return {
|
|
43
|
+
kind: folder === 'languages.toml' ? 'Languages' : 'Schema version',
|
|
44
|
+
name: folder,
|
|
45
|
+
}
|
|
46
|
+
return { kind: FOLDER[folder] ?? folder, name: rest.join('/').replace(/\.toml$/, '') }
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** The files an upload may be. */
|
|
50
|
+
export const ACCEPT = '.zip,.toml'
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Settings → Schema (story 342): the site's types and definitions downloaded
|
|
3
|
+
* as TOML, and schema files uploaded to wait for approval on the Changes
|
|
4
|
+
* dashboard. Administrators only.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { css, html, nothing } from '@umbraco-cms/backoffice/external/lit'
|
|
8
|
+
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'
|
|
9
|
+
import { downloadFile } from './download.js'
|
|
10
|
+
import { exportUrl, fetchPending, uploadSchema } from './schema-transfer-client.js'
|
|
11
|
+
import { ACCEPT, describeImport } from './schema-transfer-words.js'
|
|
12
|
+
|
|
13
|
+
const changesPath = () =>
|
|
14
|
+
`${(document.querySelector('base')?.getAttribute('href') ?? '/umbraco/').replace(/\/$/, '')}/section/settings/dashboard/changes`
|
|
15
|
+
|
|
16
|
+
export default class CromboloSchemaTransferElement extends UmbLitElement {
|
|
17
|
+
static properties = {
|
|
18
|
+
_state: { state: true },
|
|
19
|
+
_problem: { state: true },
|
|
20
|
+
_problems: { state: true },
|
|
21
|
+
_busy: { state: true },
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
constructor() {
|
|
25
|
+
super()
|
|
26
|
+
this._state = undefined
|
|
27
|
+
this._problem = ''
|
|
28
|
+
this._problems = []
|
|
29
|
+
this._busy = false
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
connectedCallback() {
|
|
33
|
+
super.connectedCallback()
|
|
34
|
+
this.#load()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async #load() {
|
|
38
|
+
const result = await fetchPending()
|
|
39
|
+
if (result.ok) this._state = { pending: result.pending, writable: result.writable }
|
|
40
|
+
else {
|
|
41
|
+
this._problem = result.message
|
|
42
|
+
this._state ??= { pending: null, writable: false }
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async #export() {
|
|
47
|
+
this._problem = ''
|
|
48
|
+
try {
|
|
49
|
+
await downloadFile(exportUrl(), 'schema.zip')
|
|
50
|
+
} catch (error) {
|
|
51
|
+
this._problem = error.message
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async #upload(event) {
|
|
56
|
+
const file = event.target.files?.[0]
|
|
57
|
+
event.target.value = ''
|
|
58
|
+
if (!file) return
|
|
59
|
+
this._busy = true
|
|
60
|
+
this._problem = ''
|
|
61
|
+
this._problems = []
|
|
62
|
+
try {
|
|
63
|
+
const result = await uploadSchema(file)
|
|
64
|
+
if (!result.ok) {
|
|
65
|
+
this._problem = result.message
|
|
66
|
+
this._problems = result.problems ?? []
|
|
67
|
+
}
|
|
68
|
+
await this.#load()
|
|
69
|
+
} finally {
|
|
70
|
+
this._busy = false
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
#pending() {
|
|
75
|
+
const pending = this._state?.pending
|
|
76
|
+
if (!pending) return nothing
|
|
77
|
+
return html`<div class="pending" role="status">
|
|
78
|
+
<uui-icon name=${pending.blocked ? 'icon-alert' : 'icon-time'}></uui-icon>
|
|
79
|
+
<div>
|
|
80
|
+
<strong>${pending.fileName}</strong> is waiting for approval: ${describeImport(pending)}.
|
|
81
|
+
${
|
|
82
|
+
pending.blocked
|
|
83
|
+
? html`Something stops it from being applied.`
|
|
84
|
+
: html`Nothing changes until it is applied.`
|
|
85
|
+
}
|
|
86
|
+
<a href=${changesPath()}>Review it on the Changes dashboard</a>
|
|
87
|
+
</div>
|
|
88
|
+
</div>`
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
render() {
|
|
92
|
+
const state = this._state
|
|
93
|
+
if (!state) return html`<uui-loader></uui-loader>`
|
|
94
|
+
return html`
|
|
95
|
+
<uui-box headline="Export">
|
|
96
|
+
<p>
|
|
97
|
+
Download this site's document, media and member types, data types, languages, forms,
|
|
98
|
+
approval workflows, user groups and webhooks, as the files the site keeps them in.
|
|
99
|
+
</p>
|
|
100
|
+
<uui-button look="primary" label="Download the schema" @click=${() => this.#export()}></uui-button>
|
|
101
|
+
</uui-box>
|
|
102
|
+
<uui-box headline="Import">
|
|
103
|
+
${
|
|
104
|
+
state.writable
|
|
105
|
+
? html`<p>
|
|
106
|
+
Upload a schema downloaded from another site, as a zip or a single file. It is
|
|
107
|
+
checked against this site and waits on the Changes dashboard until an administrator
|
|
108
|
+
applies it.
|
|
109
|
+
</p>
|
|
110
|
+
${this.#pending()}
|
|
111
|
+
<label class="upload">
|
|
112
|
+
<uui-button
|
|
113
|
+
look="secondary"
|
|
114
|
+
label=${state.pending ? 'Upload instead' : 'Upload a schema'}
|
|
115
|
+
?disabled=${this._busy}
|
|
116
|
+
@click=${() => this.renderRoot.querySelector('input[type=file]')?.click()}
|
|
117
|
+
></uui-button>
|
|
118
|
+
<input type="file" accept=${ACCEPT} hidden @change=${(event) => this.#upload(event)} />
|
|
119
|
+
</label>
|
|
120
|
+
${state.pending ? html`<p class="note">A new upload replaces the one waiting.</p>` : nothing}`
|
|
121
|
+
: html`<p class="note">
|
|
122
|
+
This site's schema changes only when the site is deployed, so it can't be imported here.
|
|
123
|
+
</p>`
|
|
124
|
+
}
|
|
125
|
+
${this._busy ? html`<uui-loader-bar></uui-loader-bar>` : nothing}
|
|
126
|
+
${this._problem ? html`<p class="problem" role="alert">${this._problem}</p>` : nothing}
|
|
127
|
+
${
|
|
128
|
+
this._problems.length > 0
|
|
129
|
+
? html`<ul class="problems">${this._problems.map((p) => html`<li>${p}</li>`)}</ul>`
|
|
130
|
+
: nothing
|
|
131
|
+
}
|
|
132
|
+
</uui-box>
|
|
133
|
+
`
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
static styles = css`
|
|
137
|
+
:host {
|
|
138
|
+
display: grid;
|
|
139
|
+
gap: var(--uui-size-layout-1);
|
|
140
|
+
padding: var(--uui-size-layout-1);
|
|
141
|
+
max-width: 72rem;
|
|
142
|
+
}
|
|
143
|
+
.pending {
|
|
144
|
+
display: flex;
|
|
145
|
+
gap: var(--uui-size-space-3);
|
|
146
|
+
align-items: flex-start;
|
|
147
|
+
padding: var(--uui-size-space-4);
|
|
148
|
+
margin-bottom: var(--uui-size-space-4);
|
|
149
|
+
border-radius: var(--uui-border-radius);
|
|
150
|
+
background: var(--uui-color-surface-alt);
|
|
151
|
+
}
|
|
152
|
+
.note {
|
|
153
|
+
color: var(--uui-color-text-alt);
|
|
154
|
+
}
|
|
155
|
+
.problem {
|
|
156
|
+
color: var(--uui-color-danger);
|
|
157
|
+
}
|
|
158
|
+
.problems {
|
|
159
|
+
margin: 0;
|
|
160
|
+
font-family: var(--uui-font-monospace, monospace);
|
|
161
|
+
font-size: var(--uui-type-small-size);
|
|
162
|
+
}
|
|
163
|
+
`
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
customElements.define('crombolo-schema-transfer', CromboloSchemaTransferElement)
|
package/plugin/settings-card.js
CHANGED
|
@@ -6,11 +6,17 @@ import { css, html, nothing } from '@umbraco-cms/backoffice/external/lit'
|
|
|
6
6
|
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'
|
|
7
7
|
|
|
8
8
|
export class CromboloSettingsCardElement extends UmbLitElement {
|
|
9
|
-
static properties = { href: {}, heading: {}, description: {} }
|
|
9
|
+
static properties = { href: {}, heading: {}, description: {}, warning: {} }
|
|
10
10
|
|
|
11
11
|
render() {
|
|
12
12
|
return html`<a href=${this.href}>
|
|
13
|
-
<strong
|
|
13
|
+
<strong
|
|
14
|
+
>${this.heading}${
|
|
15
|
+
this.warning
|
|
16
|
+
? html`<uui-icon name="icon-alert" title=${this.warning} aria-label=${this.warning}></uui-icon>`
|
|
17
|
+
: nothing
|
|
18
|
+
}</strong
|
|
19
|
+
>
|
|
14
20
|
${this.description ? html`<span>${this.description}</span>` : nothing}
|
|
15
21
|
</a>`
|
|
16
22
|
}
|
|
@@ -41,11 +47,19 @@ export class CromboloSettingsCardElement extends UmbLitElement {
|
|
|
41
47
|
outline-offset: 2px;
|
|
42
48
|
}
|
|
43
49
|
strong {
|
|
50
|
+
display: flex;
|
|
51
|
+
align-items: center;
|
|
52
|
+
justify-content: space-between;
|
|
53
|
+
gap: var(--uui-size-space-3);
|
|
44
54
|
padding: var(--uui-size-space-4) var(--uui-size-space-5);
|
|
45
55
|
background: var(--crombolo-card-header-background, var(--uui-color-header-surface));
|
|
46
56
|
color: var(--crombolo-card-header-text, var(--uui-color-header-contrast-emphasis));
|
|
47
57
|
font-weight: 700;
|
|
48
58
|
}
|
|
59
|
+
strong uui-icon {
|
|
60
|
+
flex: none;
|
|
61
|
+
color: var(--uui-color-warning-standalone, var(--uui-color-warning));
|
|
62
|
+
}
|
|
49
63
|
span {
|
|
50
64
|
padding: var(--uui-size-space-4) var(--uui-size-space-5) var(--uui-size-space-5);
|
|
51
65
|
color: var(--uui-color-text-alt);
|