@crombolo/backoffice-host 0.42.1 → 0.44.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.
@@ -0,0 +1,239 @@
1
+ /**
2
+ * The Settings landing page's cards and which tree an editor sits beside
3
+ * (story 234). Pure, so the unit tests read it outside a browser.
4
+ */
5
+
6
+ export const STRUCTURE_MENU = 'Umb.Menu.StructureSettings'
7
+ export const CODE_MENU = 'Umb.Menu.Templating'
8
+ export const ADVANCED_MENU = 'Umb.Menu.AdvancedSettings'
9
+
10
+ /** The sidebar app that draws each tree. */
11
+ export const SIDEBAR_APPS = {
12
+ structure: 'Umb.SectionSidebarMenu.Settings',
13
+ code: 'Umb.SectionSidebarMenu.Templating',
14
+ }
15
+
16
+ export const GROUPS = ['Build', 'Site', 'Health', 'History', 'Developers', 'Extensions', 'Other']
17
+
18
+ /** Our words for each tool, by the alias of its dashboard or menu item. */
19
+ export const CARDS = {
20
+ structure: {
21
+ group: 'Build',
22
+ title: 'Structure',
23
+ description: 'Content, media and member types, data types and languages.',
24
+ },
25
+ code: {
26
+ group: 'Build',
27
+ title: 'Code',
28
+ description: 'Components, stylesheets and scripts.',
29
+ },
30
+ 'Umb.Dashboard.ModelsBuilder': {
31
+ group: 'Build',
32
+ title: 'Types for code',
33
+ description: 'The TypeScript types written from the schema, and whether they are out of date.',
34
+ },
35
+ 'Crombolo.Dashboard.Workflows': {
36
+ group: 'Build',
37
+ title: 'Workflows',
38
+ description:
39
+ 'The approval steps a page goes through before it is published, and who decides each.',
40
+ },
41
+ 'Crombolo.Dashboard.Seo': {
42
+ group: 'Site',
43
+ title: 'Search & sharing',
44
+ description:
45
+ 'What every page falls back to in search results and when shared, the robots file and the missing-page page.',
46
+ },
47
+ 'Crombolo.Dashboard.Addresses': {
48
+ group: 'Site',
49
+ title: 'Page addresses',
50
+ description: "Whether the top-level page's name is part of every address below it.",
51
+ },
52
+ 'Umb.Dashboard.RedirectManagement': {
53
+ group: 'Site',
54
+ title: 'Redirects',
55
+ description: "Old addresses that send visitors on to a page's new one.",
56
+ },
57
+ 'Umb.MenuItem.Webhook': {
58
+ group: 'Site',
59
+ title: 'Webhooks',
60
+ description: 'Tell other systems when content changes.',
61
+ },
62
+ 'Umb.MenuItem.LogViewer': {
63
+ group: 'Site',
64
+ title: 'Logs',
65
+ description: 'Search and read what the server has logged.',
66
+ },
67
+ 'Umb.Dashboard.ExamineManagement': {
68
+ group: 'Site',
69
+ title: 'Search indexes',
70
+ description: "The back office's search indexes: their health, and rebuilding them.",
71
+ },
72
+ 'Crombolo.Dashboard.BackgroundJobs': {
73
+ group: 'Site',
74
+ title: 'Background jobs',
75
+ description: 'Scheduled and queued work, how far each got, and running a failed one again.',
76
+ },
77
+ 'Umb.Dashboard.HealthCheck': {
78
+ group: 'Health',
79
+ title: 'Health check',
80
+ description: "Checks on the site's setup and data, with a fix where there is one.",
81
+ },
82
+ 'Umb.Dashboard.PublishedStatus': {
83
+ group: 'Health',
84
+ title: 'Published status',
85
+ description: 'The published cache visitors are served from, and rebuilding it.',
86
+ },
87
+ 'Umb.MenuItem.Relations': {
88
+ group: 'Health',
89
+ title: 'Relations',
90
+ description: 'How items point at each other, such as a copy and its original.',
91
+ },
92
+ 'Crombolo.Dashboard.Changes': {
93
+ group: 'History',
94
+ title: 'Changes',
95
+ description: 'What an upgrade or an arriving bundle needs from you, and what is resolved.',
96
+ },
97
+ 'Crombolo.Dashboard.AuditLog': {
98
+ group: 'History',
99
+ title: 'Audit log',
100
+ description: 'Who did what, when and from where.',
101
+ },
102
+ // Story 238: a developer's view of what is loaded, apart from installing bundles.
103
+ 'Umb.MenuItem.Extensions': {
104
+ group: 'Developers',
105
+ title: 'Extension insights',
106
+ description: 'What the back office has loaded, and from which bundle.',
107
+ },
108
+ 'Crombolo.Dashboard.CiAccess': {
109
+ group: 'Developers',
110
+ title: 'CI access',
111
+ description: 'The CI jobs that may pull and push here without a person, and what each may do.',
112
+ },
113
+ 'Crombolo.Dashboard.Bundles': {
114
+ group: 'Extensions',
115
+ title: 'Bundles',
116
+ description: 'Find, install and build bundles: what they add, and turning them off.',
117
+ },
118
+ }
119
+
120
+ /**
121
+ * The landing page's groups, in order, each with its cards in the order above.
122
+ * `dashboards` are `{ alias, label, description?, bundle?, path }`; `advanced`
123
+ * are `{ alias, label, description?, bundle?, entityType }`. A card this file
124
+ * has no words for takes its manifest's description, and a bundle's card goes
125
+ * under the bundle's name, its group linking to the bundle. `structure` and `code` say whether the user may
126
+ * open an item of that tree. Paths are relative to the section.
127
+ *
128
+ * @param {{
129
+ * dashboards?: { alias: string, label?: string, description?: string, bundle?: { name: string, packageName: string }, path: string }[],
130
+ * advanced?: { alias: string, label?: string, description?: string, bundle?: { name: string, packageName: string }, entityType: string }[],
131
+ * structure?: boolean,
132
+ * code?: boolean,
133
+ * }} from
134
+ * @returns {{ group: string, bundle?: { name: string, packageName: string, path: string }, cards: any[] }[]}
135
+ */
136
+ export function settingsCards({ dashboards = [], advanced = [], structure = false, code = false }) {
137
+ const found = []
138
+ if (structure) found.push({ alias: 'structure', path: 'structure' })
139
+ if (code) found.push({ alias: 'code', path: 'code' })
140
+ for (const d of dashboards)
141
+ found.push({
142
+ alias: d.alias,
143
+ label: d.label,
144
+ description: d.description,
145
+ bundle: d.bundle,
146
+ path: d.path,
147
+ })
148
+ for (const item of advanced)
149
+ found.push({
150
+ alias: item.alias,
151
+ label: item.label,
152
+ description: item.description,
153
+ bundle: item.bundle,
154
+ path: `workspace/${item.entityType}`,
155
+ })
156
+
157
+ const order = Object.keys(CARDS)
158
+ const cards = found
159
+ .map((card) => {
160
+ const words = CARDS[card.alias]
161
+ return words
162
+ ? { alias: card.alias, path: card.path, ...words }
163
+ : {
164
+ alias: card.alias,
165
+ path: card.path,
166
+ group: card.bundle?.name ?? 'Other',
167
+ bundle: card.bundle,
168
+ title: card.label ?? card.alias,
169
+ description: card.description,
170
+ }
171
+ })
172
+ .sort((a, b) => rank(order, a.alias) - rank(order, b.alias))
173
+
174
+ const builtIn = GROUPS.map((group) => ({
175
+ group,
176
+ cards: cards.filter((c) => !c.bundle && c.group === group),
177
+ }))
178
+ // A bundle's cards are a group of their own, after ours, by the bundle's name.
179
+ const bundles = [
180
+ ...new Map(cards.flatMap((c) => (c.bundle ? [[c.bundle.packageName, c.bundle]] : []))).values(),
181
+ ]
182
+ .sort((a, b) => a.name.localeCompare(b.name))
183
+ .map((bundle) => ({
184
+ group: bundle.name,
185
+ bundle: { ...bundle, path: bundlePath(bundle.packageName) },
186
+ cards: cards.filter((c) => c.bundle?.packageName === bundle.packageName),
187
+ }))
188
+ return [...builtIn, ...bundles].filter((g) => g.cards.length > 0)
189
+ }
190
+
191
+ /** Where the Bundles section shows an installed bundle, relative to the back office. */
192
+ export const bundlePath = (packageName) =>
193
+ `section/settings/dashboard/bundles/installed?bundle=${encodeURIComponent(packageName)}`
194
+
195
+ const rank = (order, alias) => {
196
+ const at = order.indexOf(alias)
197
+ return at === -1 ? order.length : at
198
+ }
199
+
200
+ const STRUCTURE_TYPES = ['document-type', 'media-type', 'member-type', 'data-type', 'language']
201
+ const CODE_TYPES = ['partial-view', 'template', 'stylesheet', 'script']
202
+
203
+ /** The tree an editor for `entityType` sits beside, or undefined for none. */
204
+ export function treeFor(entityType) {
205
+ if (typeof entityType !== 'string') return undefined
206
+ if (STRUCTURE_TYPES.some((type) => entityType.startsWith(type))) return 'structure'
207
+ if (CODE_TYPES.some((type) => entityType.startsWith(type))) return 'code'
208
+ return undefined
209
+ }
210
+
211
+ /**
212
+ * The trail above a Settings page: Settings, then the tree or tool it is in.
213
+ * Paths are relative to the section; the last crumb is the page itself.
214
+ *
215
+ * @param {{ tree?: 'structure' | 'code', title?: string }} at
216
+ */
217
+ export function crumbsFor({ tree, title } = {}) {
218
+ const settings = { label: 'Settings', path: '' }
219
+ if (tree) return [settings, { label: CARDS[tree]?.title ?? tree }]
220
+ if (title) return [settings, { label: title }]
221
+ return []
222
+ }
223
+
224
+ /**
225
+ * The card title of the Advanced tool an editor belongs to, by the entity type
226
+ * the editor opened, e.g. `webhook` for a webhook under `webhook-root`.
227
+ *
228
+ * @param {{ alias: string, label?: string, entityType?: string }[]} advanced
229
+ * @param {string | undefined} entityType
230
+ */
231
+ export function advancedToolTitle(advanced, entityType) {
232
+ if (typeof entityType !== 'string') return undefined
233
+ const item = advanced.find(
234
+ (m) =>
235
+ typeof m.entityType === 'string' &&
236
+ (entityType === m.entityType || entityType.startsWith(m.entityType.replace(/-root$/, ''))),
237
+ )
238
+ return item ? (CARDS[item.alias]?.title ?? item.label) : undefined
239
+ }
@@ -0,0 +1,466 @@
1
+ /**
2
+ * Settings, laid out as Crombolo's (story 234): a landing page of cards, each
3
+ * tool on its own without a tab bar, and the Structure or Code tree only beside
4
+ * the editors it opens. Built from the pieces Umbraco's `umb-section-default`
5
+ * uses, and drawn in its place through the `Crombolo.SectionLayout.Settings`
6
+ * manifest.
7
+ */
8
+
9
+ import {
10
+ createExtensionApi,
11
+ createExtensionElement,
12
+ UmbExtensionsElementInitializer,
13
+ UmbExtensionsManifestInitializer,
14
+ } from '@umbraco-cms/backoffice/extension-api'
15
+ import { umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registry'
16
+ import { css, html, nothing } from '@umbraco-cms/backoffice/external/lit'
17
+ import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'
18
+ import { UmbRouteNotFoundElement } from '@umbraco-cms/backoffice/router'
19
+ import { UmbTextStyles } from '@umbraco-cms/backoffice/style'
20
+ import { aliasToPath, pathFolderName } from '@umbraco-cms/backoffice/utils'
21
+ import { UmbViewController } from '@umbraco-cms/backoffice/view'
22
+ import {
23
+ ADVANCED_MENU,
24
+ advancedToolTitle,
25
+ CODE_MENU,
26
+ crumbsFor,
27
+ SIDEBAR_APPS,
28
+ STRUCTURE_MENU,
29
+ settingsCards,
30
+ treeFor,
31
+ } from './settings-cards.js'
32
+ import './breadcrumb.js'
33
+ import './settings-card.js'
34
+
35
+ const base = () =>
36
+ (document.querySelector('base')?.getAttribute('href') ?? '/umbraco/').replace(/\/$/, '')
37
+
38
+ /** Whether this site can send e-mail; the server answers with the reason. */
39
+ const emailStatus = async () => {
40
+ const response = await fetch(`${base()}/crombolo/api/email`, {
41
+ credentials: 'include',
42
+ headers: { accept: 'application/json' },
43
+ })
44
+ if (!response.ok) throw new Error(`email responded ${response.status}`)
45
+ return response.json()
46
+ }
47
+
48
+ const menuOf = (manifest, menu) => manifest.meta?.menus?.includes(menu) === true
49
+
50
+ export class CromboloSettingsSectionElement extends UmbLitElement {
51
+ static properties = {
52
+ _routes: { state: true },
53
+ _sidebarApps: { state: true },
54
+ _tree: { state: true },
55
+ _crumbs: { state: true },
56
+ }
57
+
58
+ #dashboards = []
59
+ #menuItems = []
60
+ #sectionRoutes = []
61
+ #landing
62
+ #viewContexts = new Map()
63
+ #providedView
64
+
65
+ constructor() {
66
+ super()
67
+ new UmbExtensionsElementInitializer(
68
+ this,
69
+ umbExtensionsRegistry,
70
+ 'sectionSidebarApp',
71
+ null,
72
+ (apps) => {
73
+ // Marked as Umbraco's section marks them, which tests and tours find them by.
74
+ for (const app of apps)
75
+ app.component?.setAttribute('data-mark', `section-sidebar:${app.manifest.alias}`)
76
+ this._sidebarApps = apps.filter((a) => Object.values(SIDEBAR_APPS).includes(a.alias))
77
+ },
78
+ )
79
+ new UmbExtensionsManifestInitializer(
80
+ this,
81
+ umbExtensionsRegistry,
82
+ 'dashboard',
83
+ null,
84
+ (dashboards) => {
85
+ this.#dashboards = dashboards.map((d) => d.manifest)
86
+ this.#createRoutes()
87
+ },
88
+ )
89
+ new UmbExtensionsManifestInitializer(
90
+ this,
91
+ umbExtensionsRegistry,
92
+ 'menuItem',
93
+ (m) => menuOf(m, STRUCTURE_MENU) || menuOf(m, CODE_MENU) || menuOf(m, ADVANCED_MENU),
94
+ (items) => {
95
+ this.#menuItems = items.map((i) => i.manifest)
96
+ this.#refreshLanding()
97
+ },
98
+ )
99
+ new UmbExtensionsManifestInitializer(
100
+ this,
101
+ umbExtensionsRegistry,
102
+ 'sectionRoute',
103
+ null,
104
+ async (extensions) => {
105
+ this.#sectionRoutes = await Promise.all(
106
+ extensions
107
+ .filter((extension) => extension.manifest.element)
108
+ .map(async (extension) => {
109
+ const api = await createExtensionApi(this, extension.manifest)
110
+ if (api) api.manifest = extension.manifest
111
+ return {
112
+ path:
113
+ api?.getPath?.() ||
114
+ extension.manifest.meta?.path ||
115
+ aliasToPath(extension.manifest.alias),
116
+ component: () => createExtensionElement(extension.manifest),
117
+ setup: (element, info) => {
118
+ api?.setup?.(element, info)
119
+ const entityType = info?.match?.params?.entityType
120
+ const tree = treeFor(entityType)
121
+ this.#showing(tree, {
122
+ title: tree ? undefined : advancedToolTitle(this.#advanced(), entityType),
123
+ })
124
+ },
125
+ }
126
+ }),
127
+ )
128
+ this.#createRoutes()
129
+ },
130
+ )
131
+ }
132
+
133
+ #label(manifest) {
134
+ const label = manifest.meta?.label ?? manifest.name ?? manifest.alias
135
+ return this.localize.string(label)
136
+ }
137
+
138
+ #description(manifest) {
139
+ const text = manifest.meta?.description
140
+ return text ? this.localize.string(text) : undefined
141
+ }
142
+
143
+ #dashboardPath(manifest) {
144
+ return `dashboard/${manifest.meta?.pathname || pathFolderName(manifest.meta?.label ?? manifest.name ?? manifest.alias)}`
145
+ }
146
+
147
+ #cards() {
148
+ return settingsCards({
149
+ dashboards: this.#dashboards.map((d) => ({
150
+ alias: d.alias,
151
+ label: this.#label(d),
152
+ description: this.#description(d),
153
+ bundle: d.cromboloBundle,
154
+ path: this.#dashboardPath(d),
155
+ })),
156
+ advanced: this.#advanced(),
157
+ structure: this.#menuItems.some((m) => menuOf(m, STRUCTURE_MENU)),
158
+ code: this.#menuItems.some((m) => menuOf(m, CODE_MENU)),
159
+ })
160
+ }
161
+
162
+ #refreshLanding() {
163
+ if (this.#landing) this.#landing.groups = this.#cards()
164
+ }
165
+
166
+ /** Which tree shows, and the trail that heads the page. */
167
+ #showing(tree, { title } = {}) {
168
+ this._tree = tree
169
+ this._crumbs = crumbsFor({ tree, title })
170
+ }
171
+
172
+ #advanced() {
173
+ return this.#menuItems
174
+ .filter((m) => menuOf(m, ADVANCED_MENU))
175
+ .map((m) => ({
176
+ alias: m.alias,
177
+ label: this.#label(m),
178
+ description: this.#description(m),
179
+ bundle: m.cromboloBundle,
180
+ entityType: m.meta?.entityType,
181
+ }))
182
+ }
183
+
184
+ #viewContext(manifest) {
185
+ let context = this.#viewContexts.get(manifest.alias)
186
+ if (!context) {
187
+ context = new UmbViewController(this, manifest.alias)
188
+ context.inherit()
189
+ this.#viewContexts.set(manifest.alias, context)
190
+ }
191
+ context.setTitle(this.#label(manifest))
192
+ return context
193
+ }
194
+
195
+ #createRoutes() {
196
+ const landing = {
197
+ component: () => document.createElement('crombolo-settings-landing'),
198
+ setup: (element) => {
199
+ this.#landing = element
200
+ this.#refreshLanding()
201
+ this.#showing(undefined)
202
+ },
203
+ }
204
+ const tree = (name) => ({
205
+ path: name,
206
+ component: () => document.createElement('crombolo-settings-tree-start'),
207
+ setup: (element) => {
208
+ element.tree = name
209
+ this.#showing(name)
210
+ },
211
+ })
212
+ const dashboards = this.#dashboards.map((manifest) => ({
213
+ path: this.#dashboardPath(manifest),
214
+ component: () => createExtensionElement(manifest),
215
+ setup: (component) => {
216
+ const context = this.#viewContext(manifest)
217
+ if (this.#providedView !== context) this.#providedView?.unprovide()
218
+ if (component) {
219
+ this.#providedView = context
220
+ context.provideAt(component)
221
+ component.manifest = manifest
222
+ }
223
+ this.#showing(undefined, { title: this.#label(manifest) })
224
+ },
225
+ }))
226
+ this._routes = [
227
+ tree('structure'),
228
+ tree('code'),
229
+ // Umbraco's welcome, which this page replaces: an address people have.
230
+ { path: 'dashboard/welcome', ...landing },
231
+ ...dashboards,
232
+ ...this.#sectionRoutes,
233
+ { path: '', pathMatch: 'full', ...landing },
234
+ { path: '**', component: UmbRouteNotFoundElement },
235
+ ]
236
+ }
237
+
238
+ #sectionPath() {
239
+ return `section/${this.manifest?.meta?.pathname ?? 'settings'}`
240
+ }
241
+
242
+ render() {
243
+ const shown = this._tree ? SIDEBAR_APPS[this._tree] : undefined
244
+ const section = this.#sectionPath()
245
+ const crumbs = (this._crumbs ?? []).map((c) => ({
246
+ label: c.label,
247
+ href: c.path === undefined ? undefined : c.path ? `${section}/${c.path}` : section,
248
+ }))
249
+ const main = html`<umb-section-main>
250
+ ${
251
+ crumbs.length > 0
252
+ ? html`<crombolo-breadcrumb class="crumbs" .items=${crumbs}></crombolo-breadcrumb>`
253
+ : nothing
254
+ }
255
+ ${this._routes ? html`<umb-router-slot .routes=${this._routes}></umb-router-slot>` : nothing}
256
+ </umb-section-main>`
257
+ // Both trees stay in the page, the one not in use hidden, as Umbraco's own
258
+ // Settings keeps its menus. A tree taken out and put back breaks: the trees
259
+ // share the section's expansion state, and a detached one still answers it.
260
+ return html`<umb-section-sidebar ?hidden=${!shown}>
261
+ ${(this._sidebarApps ?? []).map(
262
+ (app) => html`<div class="tree" ?hidden=${app.alias !== shown}>${app.component}</div>`,
263
+ )}
264
+ </umb-section-sidebar>
265
+ ${main}`
266
+ }
267
+
268
+ static styles = [
269
+ UmbTextStyles,
270
+ css`
271
+ :host {
272
+ flex: 1 1 auto;
273
+ height: 100%;
274
+ display: flex;
275
+ }
276
+ umb-section-sidebar {
277
+ --umb-section-sidebar-width: 300px;
278
+ }
279
+ umb-section-sidebar[hidden],
280
+ .tree[hidden] {
281
+ display: none;
282
+ }
283
+ umb-section-main {
284
+ flex: 1 1 auto;
285
+ }
286
+ /* Umbraco's own views scroll inside their layout; the landing page and a
287
+ tree's start page have none, so the area under the trail scrolls them. */
288
+ umb-router-slot {
289
+ display: block;
290
+ flex: 1 1 auto;
291
+ min-height: 0;
292
+ overflow-y: auto;
293
+ }
294
+ .crumbs {
295
+ display: block;
296
+ padding: var(--uui-size-space-4) var(--uui-size-layout-1) 0;
297
+ }
298
+ `,
299
+ ]
300
+ }
301
+
302
+ /** The landing page: a box of cards per group, and e-mail when it is not set up. */
303
+ export class CromboloSettingsLandingElement extends UmbLitElement {
304
+ static properties = { groups: { attribute: false }, _email: { state: true } }
305
+
306
+ connectedCallback() {
307
+ super.connectedCallback()
308
+ // An explanation, not a control: a failure leaves it out.
309
+ emailStatus().then(
310
+ (status) => {
311
+ this._email = status
312
+ },
313
+ () => {},
314
+ )
315
+ }
316
+
317
+ #email() {
318
+ const status = this._email
319
+ if (!status || status.available) return nothing
320
+ return html`<div class="banner" role="status">
321
+ <uui-icon name="icon-alert"></uui-icon>
322
+ <p>
323
+ <strong>E-mail is not set up.</strong>
324
+ ${status.reason}
325
+ ${
326
+ status.affects?.length > 0
327
+ ? html`Until it is, these are unavailable: ${status.affects.join(', ')}.`
328
+ : nothing
329
+ }
330
+ </p>
331
+ </div>`
332
+ }
333
+
334
+ render() {
335
+ return html`
336
+ ${this.#email()}
337
+ ${(this.groups ?? []).map(
338
+ ({ group, bundle, cards }) => html`<section>
339
+ <h2>
340
+ ${group}
341
+ ${
342
+ bundle
343
+ ? html`<a class="tag" href=${bundle.path} title=${`The ${bundle.name} bundle, which adds these`}
344
+ >Bundle: ${bundle.packageName}</a
345
+ >`
346
+ : nothing
347
+ }
348
+ </h2>
349
+ <div class="cards">
350
+ ${cards.map(
351
+ (card) =>
352
+ html`<crombolo-settings-card
353
+ href=${`section/settings/${card.path}`}
354
+ heading=${card.title}
355
+ description=${card.description ?? ''}
356
+ ></crombolo-settings-card>`,
357
+ )}
358
+ </div>
359
+ </section>`,
360
+ )}
361
+ `
362
+ }
363
+
364
+ static styles = [
365
+ UmbTextStyles,
366
+ css`
367
+ :host {
368
+ display: block;
369
+ padding: var(--uui-size-layout-1);
370
+ max-width: 72rem;
371
+ }
372
+ section + section {
373
+ margin-top: var(--uui-size-layout-2);
374
+ }
375
+ h2 {
376
+ font-size: var(--uui-type-h5-size);
377
+ font-weight: 800;
378
+ letter-spacing: -0.01em;
379
+ margin: 0 0 var(--uui-size-space-4);
380
+ }
381
+ h2 .tag {
382
+ margin-left: var(--uui-size-space-2);
383
+ padding: 0.1em 0.6em;
384
+ border: 1px solid var(--uui-color-border-standalone);
385
+ border-radius: 999px;
386
+ color: var(--uui-color-text-alt);
387
+ font-size: var(--uui-type-small-size);
388
+ font-weight: 600;
389
+ letter-spacing: 0;
390
+ vertical-align: middle;
391
+ text-decoration: none;
392
+ }
393
+ h2 a.tag:hover,
394
+ h2 a.tag:focus-visible {
395
+ border-color: var(--uui-color-interactive-emphasis);
396
+ color: var(--uui-color-interactive-emphasis);
397
+ }
398
+ .cards {
399
+ display: grid;
400
+ grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
401
+ gap: var(--uui-size-space-5);
402
+ }
403
+ .banner {
404
+ display: flex;
405
+ gap: var(--uui-size-space-4);
406
+ align-items: flex-start;
407
+ margin-bottom: var(--uui-size-layout-1);
408
+ padding: var(--uui-size-space-4) var(--uui-size-space-5);
409
+ border: 1px solid color-mix(in srgb, var(--uui-color-warning) 45%, transparent);
410
+ border-left-width: 4px;
411
+ border-radius: 8px;
412
+ background: color-mix(in srgb, var(--uui-color-warning) 12%, var(--uui-color-surface));
413
+ color: var(--uui-color-text);
414
+ }
415
+ .banner uui-icon {
416
+ flex: none;
417
+ margin-top: 0.15em;
418
+ color: var(--uui-color-warning-standalone, var(--uui-color-warning));
419
+ }
420
+ .banner p {
421
+ margin: 0;
422
+ line-height: 1.5;
423
+ }
424
+ `,
425
+ ]
426
+ }
427
+
428
+ const TREE_HELP = {
429
+ structure: html`<p>
430
+ Choose a type, data type or language in the tree to edit it.
431
+ </p>
432
+ <p>
433
+ Content types, data types and languages are <strong>files</strong>, in
434
+ <code>schema/</code>, written as TOML. What you change here is written to the file, and the
435
+ file is what a deploy and every other server reads, so a change can be reviewed like code.
436
+ </p>`,
437
+ code: html`<p>Choose a component, stylesheet or script in the tree to edit it.</p>`,
438
+ }
439
+
440
+ /** What Structure or Code shows until something in its tree is chosen. */
441
+ export class CromboloSettingsTreeStartElement extends UmbLitElement {
442
+ static properties = { tree: { attribute: false } }
443
+
444
+ render() {
445
+ return html`<uui-box headline=${this.tree === 'code' ? 'Code' : 'Structure'}
446
+ >${TREE_HELP[this.tree] ?? nothing}</uui-box
447
+ >`
448
+ }
449
+
450
+ static styles = [
451
+ UmbTextStyles,
452
+ css`
453
+ :host {
454
+ display: block;
455
+ padding: var(--uui-size-layout-1);
456
+ max-width: 48rem;
457
+ }
458
+ `,
459
+ ]
460
+ }
461
+
462
+ customElements.define('crombolo-settings-section', CromboloSettingsSectionElement)
463
+ customElements.define('crombolo-settings-landing', CromboloSettingsLandingElement)
464
+ customElements.define('crombolo-settings-tree-start', CromboloSettingsTreeStartElement)
465
+
466
+ export default CromboloSettingsSectionElement