@crombolo/backoffice-host 0.41.1 → 0.42.1
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/addresses-dashboard.js +3 -2
- package/plugin/app-preview/umbraco-package.json +1 -1
- package/plugin/audit-dashboard.js +3 -2
- package/plugin/branding/localization-en.js +9 -3
- package/plugin/branding/sign-in.js +0 -31
- package/plugin/changes-dashboard.js +3 -2
- package/plugin/edit-conflicts.js +11 -21
- package/plugin/jobs-dashboard.js +3 -2
- package/plugin/localizations/umbraco-package.json +1 -1
- package/plugin/notifications-dialog.js +8 -35
- package/plugin/seo/umbraco-package.json +1 -1
- package/plugin/side-panel/host.js +7 -63
- package/plugin/side-panel/layout.js +0 -15
- package/plugin/sign-in/umbraco-package.json +1 -1
- package/plugin/tsx-editors.js +56 -164
- package/plugin/umbraco-package.json +2 -26
- package/plugin/branding/branding.js +0 -188
- package/plugin/branding/client-credentials.js +0 -49
- package/plugin/branding/log-viewer-menu.js +0 -70
- package/plugin/branding/query-builder.js +0 -28
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crombolo/backoffice-host",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.42.1",
|
|
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": "
|
|
35
|
+
"@crombolo/core": "0.42.1",
|
|
36
|
+
"@crombolo/backoffice-dist": "0.42.1"
|
|
37
37
|
}
|
|
38
38
|
}
|
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
* below it, as Umbraco's `HideTopLevelNodeFromPath` sets it. Saving moves the
|
|
4
4
|
* addresses, and the old ones redirect to the new. docs/rendering.md, "URLs".
|
|
5
5
|
*/
|
|
6
|
-
import { css, html,
|
|
6
|
+
import { css, html, nothing } from '@umbraco-cms/backoffice/external/lit'
|
|
7
|
+
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'
|
|
7
8
|
|
|
8
9
|
const endpoint = () =>
|
|
9
10
|
`${(document.querySelector('base')?.getAttribute('href') ?? '/umbraco/').replace(/\/$/, '')}/crombolo/api/url-options`
|
|
10
11
|
|
|
11
|
-
export default class CromboloAddressesDashboardElement extends
|
|
12
|
+
export default class CromboloAddressesDashboardElement extends UmbLitElement {
|
|
12
13
|
static properties = {
|
|
13
14
|
_settings: { state: true },
|
|
14
15
|
_showTopLevel: { state: true },
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* newest first, filtered by person, kind of change, words and dates.
|
|
4
4
|
* docs/audit-log.md.
|
|
5
5
|
*/
|
|
6
|
-
import { css, html,
|
|
6
|
+
import { css, html, nothing } from '@umbraco-cms/backoffice/external/lit'
|
|
7
|
+
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'
|
|
7
8
|
|
|
8
9
|
const PAGE_SIZE = 50
|
|
9
10
|
|
|
@@ -133,7 +134,7 @@ function fromWhere(entry) {
|
|
|
133
134
|
return forwarded || entry.ipAddress || '—'
|
|
134
135
|
}
|
|
135
136
|
|
|
136
|
-
export default class CromboloAuditDashboardElement extends
|
|
137
|
+
export default class CromboloAuditDashboardElement extends UmbLitElement {
|
|
137
138
|
static properties = {
|
|
138
139
|
_page: { state: true },
|
|
139
140
|
_users: { state: true },
|
|
@@ -11,9 +11,10 @@
|
|
|
11
11
|
* one that wins. See `localization.registry.js`: `$weight: extension.weight ?? 100`.
|
|
12
12
|
*
|
|
13
13
|
* Only what a person reads in a flow this CMS implements. Strings about
|
|
14
|
-
* `appsettings.json`, IIS permissions
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
* `appsettings.json`, IIS permissions or the .NET installer are left alone: they
|
|
15
|
+
* name real things that are not ours to rename, and the features they belong to
|
|
16
|
+
* are not built. Examine is the exception: the search dashboard is built, over
|
|
17
|
+
* the database's own indexes, so its tab and heading say what it is.
|
|
17
18
|
*
|
|
18
19
|
* `sections` and `packager` are the other kind of rename: not the product's name
|
|
19
20
|
* but a feature's. Umbraco's Packages section builds a `.umb` file; the artifact
|
|
@@ -65,6 +66,11 @@ export default {
|
|
|
65
66
|
},
|
|
66
67
|
dashboardTabs: {
|
|
67
68
|
contentIntro: 'Welcome to Crombolo',
|
|
69
|
+
// Search here is the database's own (docs/search.md), not Examine.
|
|
70
|
+
settingsExamine: 'Search indexes',
|
|
71
|
+
},
|
|
72
|
+
examineManagement: {
|
|
73
|
+
manageIndexes: 'Manage search indexes',
|
|
68
74
|
},
|
|
69
75
|
languages: {
|
|
70
76
|
defaultLanguageHelp: 'A Crombolo site can only have one default language set.',
|
|
@@ -66,38 +66,7 @@ class CromboloAuthProviderElement extends LitElement {
|
|
|
66
66
|
|
|
67
67
|
if (!customElements.get(TAG)) customElements.define(TAG, CromboloAuthProviderElement)
|
|
68
68
|
|
|
69
|
-
/**
|
|
70
|
-
* Signing in again after a timeout closes its modal twice.
|
|
71
|
-
*
|
|
72
|
-
* `umb-app-auth-modal` submits when the session reports itself authorised, and
|
|
73
|
-
* `umb-auth-view` calls the same submit as its `onSuccess` once
|
|
74
|
-
* `makeAuthorizationRequest` returns. Whichever runs first closes the modal and
|
|
75
|
-
* destroys its value state, so the second's `value = { success: true }` throws
|
|
76
|
-
* `_subject is undefined` — and the view shows that as a sign-in error, though
|
|
77
|
-
* the editor is signed in. The second assignment has nothing left to say, so it
|
|
78
|
-
* is dropped. Patched on the element's prototype, as `tsx-editors.js` patches
|
|
79
|
-
* upstream, rather than in the vendored bundle.
|
|
80
|
-
*/
|
|
81
|
-
async function guardTimedOutSignIn() {
|
|
82
|
-
const Modal = await customElements.whenDefined('umb-app-auth-modal')
|
|
83
|
-
let descriptor
|
|
84
|
-
for (let proto = Modal.prototype; proto && !descriptor; proto = Object.getPrototypeOf(proto))
|
|
85
|
-
descriptor = Object.getOwnPropertyDescriptor(proto, 'value')
|
|
86
|
-
if (!descriptor?.set) return
|
|
87
|
-
const { get, set } = descriptor
|
|
88
|
-
Object.defineProperty(Modal.prototype, 'value', {
|
|
89
|
-
configurable: true,
|
|
90
|
-
get,
|
|
91
|
-
set(value) {
|
|
92
|
-
if (this.__cromboloSubmitted) return
|
|
93
|
-
set.call(this, value)
|
|
94
|
-
this.__cromboloSubmitted = true
|
|
95
|
-
},
|
|
96
|
-
})
|
|
97
|
-
}
|
|
98
|
-
|
|
99
69
|
export const onInit = (_host, extensionRegistry) => {
|
|
100
|
-
void guardTimedOutSignIn()
|
|
101
70
|
extensionRegistry.unregister(VENDORED)
|
|
102
71
|
extensionRegistry.register({
|
|
103
72
|
type: 'authProvider',
|
|
@@ -14,7 +14,8 @@
|
|
|
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
16
|
*/
|
|
17
|
-
import { css, html,
|
|
17
|
+
import { css, html, nothing } from '@umbraco-cms/backoffice/external/lit'
|
|
18
|
+
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'
|
|
18
19
|
import { downloadFile } from './download.js'
|
|
19
20
|
import { answersUrl, fetchReport, transferAction } from './report-client.js'
|
|
20
21
|
|
|
@@ -32,7 +33,7 @@ const ANSWERED_LABEL = {
|
|
|
32
33
|
skip: 'is left out',
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
export default class CromboloChangesDashboardElement extends
|
|
36
|
+
export default class CromboloChangesDashboardElement extends UmbLitElement {
|
|
36
37
|
static properties = {
|
|
37
38
|
_report: { state: true },
|
|
38
39
|
_error: { state: true },
|
package/plugin/edit-conflicts.js
CHANGED
|
@@ -92,37 +92,27 @@ export const CONFLICT_BANNER = {
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
/**
|
|
95
|
-
*
|
|
96
|
-
*
|
|
95
|
+
* What the fork's `onEntityLoad` seam calls as an editor reads its entity: for a
|
|
96
|
+
* page, the tracker knows the read is the editor's own until it ends.
|
|
97
97
|
*/
|
|
98
|
-
export function
|
|
99
|
-
|
|
100
|
-
const
|
|
101
|
-
if (
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
if (this.getEntityType?.() !== 'document' || !key) return original.call(this, unique)
|
|
105
|
-
revisions.beginLoad(key)
|
|
106
|
-
try {
|
|
107
|
-
return await original.call(this, unique)
|
|
108
|
-
} finally {
|
|
109
|
-
revisions.endLoad(key)
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
wrapped.cromboloRevisions = true
|
|
113
|
-
base.prototype[method] = wrapped
|
|
98
|
+
export function entityLoads(revisions = tracker) {
|
|
99
|
+
return (entityType, unique) => {
|
|
100
|
+
const key = String(unique ?? '').toLowerCase()
|
|
101
|
+
if (entityType !== 'document' || !key) return undefined
|
|
102
|
+
revisions.beginLoad(key)
|
|
103
|
+
return () => revisions.endLoad(key)
|
|
114
104
|
}
|
|
115
105
|
}
|
|
116
106
|
|
|
117
107
|
export const onInit = async (_host, extensionRegistry) => {
|
|
118
|
-
const [{ umbHttpClient }, {
|
|
108
|
+
const [{ umbHttpClient }, { umbCromboloHooks }] = await Promise.all([
|
|
119
109
|
import('@umbraco-cms/backoffice/http-client'),
|
|
120
|
-
import('@umbraco-cms/backoffice/
|
|
110
|
+
import('@umbraco-cms/backoffice/extension-registry'),
|
|
121
111
|
])
|
|
122
112
|
umbHttpClient.interceptors.request.use((request) => tracker.onRequest(request))
|
|
123
113
|
umbHttpClient.interceptors.response.use((response, request) =>
|
|
124
114
|
tracker.onResponse(response, request),
|
|
125
115
|
)
|
|
126
|
-
|
|
116
|
+
umbCromboloHooks.onEntityLoad = entityLoads()
|
|
127
117
|
extensionRegistry.register(CONFLICT_BANNER)
|
|
128
118
|
}
|
package/plugin/jobs-dashboard.js
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* bundles' jobs, newest first, filtered by state, each with how far it got and
|
|
4
4
|
* why it failed, and a failed one run again by hand.
|
|
5
5
|
*/
|
|
6
|
-
import { css, html,
|
|
6
|
+
import { css, html, nothing } from '@umbraco-cms/backoffice/external/lit'
|
|
7
|
+
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'
|
|
7
8
|
|
|
8
9
|
const PAGE_SIZE = 50
|
|
9
10
|
|
|
@@ -45,7 +46,7 @@ function progressOf(job) {
|
|
|
45
46
|
return p.note ? `${count}: ${p.note}` : count
|
|
46
47
|
}
|
|
47
48
|
|
|
48
|
-
export default class CromboloJobsDashboardElement extends
|
|
49
|
+
export default class CromboloJobsDashboardElement extends UmbLitElement {
|
|
49
50
|
static properties = {
|
|
50
51
|
_items: { state: true },
|
|
51
52
|
_total: { state: true },
|
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Umbraco's notifications dialog, on a site that cannot send e-mail (story
|
|
3
3
|
* 045): a banner saying so, and every toggle disabled, rather than choices
|
|
4
|
-
* saved for e-mails that never come.
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* patched rather than replaced, as the log viewer's menu is: once the element
|
|
8
|
-
* is defined, each update disables its toggles and Save and puts the banner
|
|
9
|
-
* above them. `tests/notifications-dialog.test.ts` pins the vendored dialog
|
|
10
|
-
* this relies on, so a re-vendor that moves it fails the suite rather than the
|
|
11
|
-
* editor. The server refuses a new subscription regardless.
|
|
4
|
+
* saved for e-mails that never come. The dialog asks the fork's
|
|
5
|
+
* `notificationsUnavailable` seam, which this answers. The server refuses a new
|
|
6
|
+
* subscription regardless.
|
|
12
7
|
*/
|
|
13
|
-
const TAG = 'umb-document-notifications-modal'
|
|
14
|
-
export const BANNER_CLASS = 'crombolo-notifications-unavailable'
|
|
15
8
|
export const UNAVAILABLE =
|
|
16
9
|
"This site can't send e-mail yet, so it can't tell you when this page changes. Ask an administrator to set up e-mail, then come back to choose what to hear about."
|
|
17
10
|
|
|
@@ -31,32 +24,12 @@ export function canSendNotifications(fetcher = fetch) {
|
|
|
31
24
|
return answer
|
|
32
25
|
}
|
|
33
26
|
|
|
34
|
-
/**
|
|
35
|
-
export function
|
|
36
|
-
|
|
37
|
-
for (const button of root.querySelectorAll('uui-button[color="positive"]')) button.disabled = true
|
|
38
|
-
const box = root.querySelector('uui-box')
|
|
39
|
-
if (!box || box.querySelector(`.${BANNER_CLASS}`)) return
|
|
40
|
-
const banner = box.ownerDocument.createElement('p')
|
|
41
|
-
banner.className = BANNER_CLASS
|
|
42
|
-
banner.setAttribute('role', 'status')
|
|
43
|
-
banner.setAttribute(
|
|
44
|
-
'style',
|
|
45
|
-
'margin: 0 0 var(--uui-size-space-4); color: var(--uui-color-text-alt);',
|
|
46
|
-
)
|
|
47
|
-
banner.textContent = message
|
|
48
|
-
box.prepend(banner)
|
|
27
|
+
/** Why the dialog's choices are off, or undefined when this site can send them. */
|
|
28
|
+
export async function notificationsUnavailable(fetcher = fetch) {
|
|
29
|
+
return (await canSendNotifications(fetcher)) ? undefined : UNAVAILABLE
|
|
49
30
|
}
|
|
50
31
|
|
|
51
32
|
export const onInit = async () => {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const prototype = element.prototype
|
|
55
|
-
const original = prototype.updated
|
|
56
|
-
prototype.updated = function patched(changed) {
|
|
57
|
-
original?.call(this, changed)
|
|
58
|
-
void canSendNotifications().then((ok) => {
|
|
59
|
-
if (!ok && this.renderRoot) markUnavailable(this.renderRoot)
|
|
60
|
-
})
|
|
61
|
-
}
|
|
33
|
+
const { umbCromboloHooks } = await import('@umbraco-cms/backoffice/extension-registry')
|
|
34
|
+
umbCromboloHooks.notificationsUnavailable = () => notificationsUnavailable()
|
|
62
35
|
}
|
|
@@ -1,69 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Side panels (story 182): a column beside the back office's main view that an
|
|
3
|
-
* extension's `sidePanel` docks into. `umb-backoffice
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* and everything open in it carry on; the panel sits outside the router, so
|
|
8
|
-
* moving around keeps it.
|
|
9
|
-
*
|
|
10
|
-
* When the shell no longer has its header and main as expected, nothing is
|
|
11
|
-
* changed: a back office without panels rather than a broken one.
|
|
12
|
-
* `tests/side-panel-plugin.test.ts` fails first.
|
|
3
|
+
* extension's `sidePanel` docks into. The shell (`umb-backoffice`, in the fork of
|
|
4
|
+
* Umbraco's client, story 235) renders `<crombolo-side-panel-host>` beside main
|
|
5
|
+
* on a grid under the header; this defines it. It sits outside main's router, so
|
|
6
|
+
* moving around keeps a panel open.
|
|
13
7
|
*/
|
|
14
8
|
import { UmbElementMixin } from '@umbraco-cms/backoffice/element-api'
|
|
15
9
|
import { UmbExtensionsElementInitializer } from '@umbraco-cms/backoffice/extension-api'
|
|
16
10
|
import { umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registry'
|
|
17
11
|
import { css, html, LitElement, nothing } from '@umbraco-cms/backoffice/external/lit'
|
|
18
|
-
import {
|
|
19
|
-
modeFor,
|
|
20
|
-
SIDE_PANEL_CONTEXT,
|
|
21
|
-
SIDE_PANEL_TYPE,
|
|
22
|
-
shellIsAsExpected,
|
|
23
|
-
widthForKey,
|
|
24
|
-
} from './layout.js'
|
|
12
|
+
import { modeFor, SIDE_PANEL_CONTEXT, SIDE_PANEL_TYPE, widthForKey } from './layout.js'
|
|
25
13
|
import './toggle.js'
|
|
26
14
|
|
|
27
|
-
const SHELL_STYLES = css`
|
|
28
|
-
:host {
|
|
29
|
-
display: grid;
|
|
30
|
-
grid-template-columns: minmax(0, 1fr) auto;
|
|
31
|
-
grid-template-rows: auto minmax(0, 1fr);
|
|
32
|
-
}
|
|
33
|
-
umb-backoffice-header {
|
|
34
|
-
grid-column: 1 / -1;
|
|
35
|
-
}
|
|
36
|
-
umb-backoffice-main {
|
|
37
|
-
grid-column: 1;
|
|
38
|
-
grid-row: 2;
|
|
39
|
-
height: 100%;
|
|
40
|
-
min-width: 0;
|
|
41
|
-
}
|
|
42
|
-
crombolo-side-panel-host {
|
|
43
|
-
grid-column: 2;
|
|
44
|
-
grid-row: 2;
|
|
45
|
-
min-height: 0;
|
|
46
|
-
}
|
|
47
|
-
`
|
|
48
|
-
|
|
49
|
-
/** Docks the panel host into a live shell once; true when this call did. */
|
|
50
|
-
export function dockInto(shell) {
|
|
51
|
-
const root = shell?.shadowRoot
|
|
52
|
-
if (!root || root.querySelector('crombolo-side-panel-host')) return false
|
|
53
|
-
const children = [...root.children].map((child) => `<${child.localName}`)
|
|
54
|
-
// `:scope` matches nothing on a shadow root, so main is found among its children.
|
|
55
|
-
const main = [...root.children].find((child) => child.localName === 'umb-backoffice-main')
|
|
56
|
-
if (!main || !shellIsAsExpected(children)) {
|
|
57
|
-
console.warn('Side panels are off: the back office shell no longer renders as expected.')
|
|
58
|
-
return false
|
|
59
|
-
}
|
|
60
|
-
const sheet = SHELL_STYLES.styleSheet
|
|
61
|
-
if (sheet && !root.adoptedStyleSheets.includes(sheet))
|
|
62
|
-
root.adoptedStyleSheets = [...root.adoptedStyleSheets, sheet]
|
|
63
|
-
main.after(document.createElement('crombolo-side-panel-host'))
|
|
64
|
-
return true
|
|
65
|
-
}
|
|
66
|
-
|
|
67
15
|
/** The header toggles registered for panels that asked for one, by panel alias. */
|
|
68
16
|
const toggles = new Map()
|
|
69
17
|
|
|
@@ -325,9 +273,5 @@ export class CromboloSidePanelHostElement extends UmbElementMixin(LitElement) {
|
|
|
325
273
|
|
|
326
274
|
customElements.define('crombolo-side-panel-host', CromboloSidePanelHostElement)
|
|
327
275
|
|
|
328
|
-
//
|
|
329
|
-
|
|
330
|
-
export const onInit = async (host) => {
|
|
331
|
-
await host?.updateComplete
|
|
332
|
-
dockInto(host)
|
|
333
|
-
}
|
|
276
|
+
// Loading this module defines the host the shell renders; nothing else to start.
|
|
277
|
+
export const onInit = () => {}
|
|
@@ -77,18 +77,3 @@ export function store(userKey, state, storage = globalThis.localStorage) {
|
|
|
77
77
|
// Private windows and blocked storage: the panel simply is not remembered.
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
-
|
|
81
|
-
/** The children `umb-backoffice` renders, in order; the layout patch needs all three. */
|
|
82
|
-
export const SHELL = ['<umb-backoffice-header', '<umb-backoffice-main', '<slot']
|
|
83
|
-
|
|
84
|
-
/** Whether a rendered template still has the shell's children in order. */
|
|
85
|
-
export function shellIsAsExpected(strings) {
|
|
86
|
-
const text = Array.isArray(strings) ? strings.join('') : String(strings ?? '')
|
|
87
|
-
let at = -1
|
|
88
|
-
for (const tag of SHELL) {
|
|
89
|
-
const next = text.indexOf(tag, at + 1)
|
|
90
|
-
if (next < 0) return false
|
|
91
|
-
at = next
|
|
92
|
-
}
|
|
93
|
-
return true
|
|
94
|
-
}
|
package/plugin/tsx-editors.js
CHANGED
|
@@ -1,26 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Makes Umbraco's template and partial view editors write and read TSX instead
|
|
3
|
-
* of Razor. Umbraco's client
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* `
|
|
11
|
-
*
|
|
12
|
-
* (`tsx-snippets.js`), and the inserts that have no TSX equivalent — a partial
|
|
13
|
-
* view, which needs an import as well as a tag, and Razor's sections — are hidden.
|
|
14
|
-
*
|
|
15
|
-
* The methods are patched on Umbraco's own classes rather than the extensions
|
|
16
|
-
* re-registered: changing the registry once the backoffice is rendering makes
|
|
17
|
-
* every open section re-evaluate its extensions, and a route set up in that
|
|
18
|
-
* window throws inside Umbraco's code.
|
|
3
|
+
* of Razor. Umbraco's client starts a template with a Razor scaffold, writes a
|
|
4
|
+
* Razor `Layout = "x.cshtml"` block for a master template, starts a partial view
|
|
5
|
+
* empty, and opens both in an editor configured for Razor. The fork of the
|
|
6
|
+
* client (story 235) asks `umbCromboloHooks` at each of those places, and this
|
|
7
|
+
* answers: a default-exported component, `export const layout = '<alias>'` for
|
|
8
|
+
* its master, the server's `Empty` snippet for a partial view, and monaco's
|
|
9
|
+
* TypeScript on a `.tsx` model. Snippets inserted into a view are translated to
|
|
10
|
+
* TSX (`tsx-snippets.js`), and the inserts with no TSX equivalent, a partial view
|
|
11
|
+
* (an import as well as a tag) and Razor's sections, are hidden.
|
|
19
12
|
*/
|
|
20
|
-
import { UmbCodeEditorElement } from '@umbraco-cms/backoffice/code-editor'
|
|
21
13
|
import { PartialViewService } from '@umbraco-cms/backoffice/external/backend-api'
|
|
22
|
-
import { UmbPartialViewDetailRepository } from '@umbraco-cms/backoffice/partial-view'
|
|
23
|
-
import { UmbTemplateDetailRepository } from '@umbraco-cms/backoffice/template'
|
|
24
14
|
import { toTsxSnippet } from './tsx-snippets.js'
|
|
25
15
|
|
|
26
16
|
export const SCAFFOLD = `import type { PageProps } from '@crombolo/crombolo'
|
|
@@ -87,9 +77,6 @@ const COMPONENTS = 'file:///components'
|
|
|
87
77
|
*/
|
|
88
78
|
const BUNDLER = 100
|
|
89
79
|
|
|
90
|
-
/** Code editors showing a view, rather than a stylesheet, a script or JSON. */
|
|
91
|
-
const views = new WeakSet()
|
|
92
|
-
|
|
93
80
|
let opened = 0
|
|
94
81
|
|
|
95
82
|
function pluginApi() {
|
|
@@ -184,154 +171,59 @@ async function configureTsx() {
|
|
|
184
171
|
}
|
|
185
172
|
|
|
186
173
|
/**
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
* `language` is a Lit property, so the accessor to wrap is the one Lit defined
|
|
191
|
-
* on the prototype. If a future version of either defines it elsewhere, the
|
|
192
|
-
* editor keeps Umbraco's Razor rather than this entry point throwing on the way
|
|
193
|
-
* in and taking the TSX scaffolds down with it.
|
|
174
|
+
* How a view's code editor works, for the fork's `viewEditor` seam: monaco's
|
|
175
|
+
* `typescript` on a model named as a `.tsx` file, configured before the editor is
|
|
176
|
+
* made, with inserted snippets translated.
|
|
194
177
|
*/
|
|
195
|
-
function
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
const view = value === TSX || value === 'razor'
|
|
202
|
-
if (view) views.add(this)
|
|
203
|
-
else views.delete(this)
|
|
204
|
-
language.set.call(this, view ? 'typescript' : value)
|
|
178
|
+
function viewEditor() {
|
|
179
|
+
let configured = { monaco: undefined, ok: false }
|
|
180
|
+
return {
|
|
181
|
+
language: 'typescript',
|
|
182
|
+
async prepare() {
|
|
183
|
+
configured = await configureTsx()
|
|
205
184
|
},
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
//
|
|
218
|
-
//
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
)
|
|
231
|
-
editor.setModel(model)
|
|
232
|
-
created.dispose()
|
|
233
|
-
editor.onDidDispose(() => model.dispose())
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
const insert = editors.insert
|
|
237
|
-
editors.insert = function (text) {
|
|
238
|
-
return insert.call(this, views.has(this) ? toTsxSnippet(text) : text)
|
|
185
|
+
created(editor) {
|
|
186
|
+
const { monaco, ok } = configured
|
|
187
|
+
const created = editor?.getModel?.()
|
|
188
|
+
if (!monaco || !created) return
|
|
189
|
+
if (!ok) {
|
|
190
|
+
// Without the dialect, TypeScript reads a view as a plain `.ts` file and
|
|
191
|
+
// underlines every tag in it. Plain text says less and lies less.
|
|
192
|
+
monaco.editor.setModelLanguage(created, 'plaintext')
|
|
193
|
+
return
|
|
194
|
+
}
|
|
195
|
+
// monaco names the model it creates `inmemory://model/1`, and a name with no
|
|
196
|
+
// `.tsx` on it is a file TypeScript refuses to read JSX in: every tag in the
|
|
197
|
+
// view would be a syntax error. So the model is replaced by one named as the
|
|
198
|
+
// file it is.
|
|
199
|
+
const model = monaco.editor.createModel(
|
|
200
|
+
created.getValue(),
|
|
201
|
+
'typescript',
|
|
202
|
+
monaco.Uri.parse(`${COMPONENTS}/view-${++opened}.tsx`),
|
|
203
|
+
)
|
|
204
|
+
editor.setModel(model)
|
|
205
|
+
created.dispose()
|
|
206
|
+
editor.onDidDispose(() => model.dispose())
|
|
207
|
+
},
|
|
208
|
+
insert: toTsxSnippet,
|
|
239
209
|
}
|
|
240
210
|
}
|
|
241
211
|
|
|
242
|
-
/**
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
})
|
|
255
|
-
|
|
256
|
-
const editor = (await customElements.whenDefined('umb-template-workspace-editor')).prototype
|
|
257
|
-
const updated = editor.updated
|
|
258
|
-
editor.updated = function (changed) {
|
|
259
|
-
updated?.call(this, changed)
|
|
260
|
-
const sections = this.shadowRoot?.querySelector('#sections-button')
|
|
261
|
-
if (sections) sections.style.display = 'none'
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
/**
|
|
266
|
-
* The value builder's preview shows the snippet it will insert, so it shows the
|
|
267
|
-
* TSX one. Its output is still Umbraco's, and is translated on insert with the rest.
|
|
268
|
-
*/
|
|
269
|
-
async function previewFieldsAsTsx() {
|
|
270
|
-
const modal = (await customElements.whenDefined('umb-templating-page-field-builder-modal'))
|
|
271
|
-
.prototype
|
|
272
|
-
const render = modal.render
|
|
273
|
-
modal.render = function () {
|
|
274
|
-
const result = render.call(this)
|
|
275
|
-
if (Array.isArray(result?.values)) result.values = result.values.map(toTsxSnippet)
|
|
276
|
-
return result
|
|
277
|
-
}
|
|
278
|
-
const updated = modal.updated
|
|
279
|
-
modal.updated = function (changed) {
|
|
280
|
-
updated?.call(this, changed)
|
|
281
|
-
const block = this.shadowRoot?.querySelector('umb-code-block')
|
|
282
|
-
if (block && block.getAttribute('language') !== 'TypeScript') {
|
|
283
|
-
block.setAttribute('language', 'TypeScript')
|
|
284
|
-
block.language = 'TypeScript'
|
|
285
|
-
}
|
|
286
|
-
}
|
|
212
|
+
/** The fork's seams, answered for TSX views. */
|
|
213
|
+
export const TSX_HOOKS = {
|
|
214
|
+
viewEditor: (language) => (language === TSX || language === 'razor' ? viewEditor() : undefined),
|
|
215
|
+
templateScaffold: () => SCAFFOLD,
|
|
216
|
+
async partialViewScaffold() {
|
|
217
|
+
const { data } = await PartialViewService.getPartialViewSnippetById({ path: { id: 'Empty' } })
|
|
218
|
+
return data?.content
|
|
219
|
+
},
|
|
220
|
+
writeLayout: withLayout,
|
|
221
|
+
translateSnippet: toTsxSnippet,
|
|
222
|
+
viewLanguageLabel: 'TypeScript',
|
|
223
|
+
hideRazorInserts: true,
|
|
287
224
|
}
|
|
288
225
|
|
|
289
226
|
export const onInit = async () => {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
hideRazorInserts()
|
|
293
|
-
previewFieldsAsTsx()
|
|
294
|
-
|
|
295
|
-
const repository = UmbTemplateDetailRepository.prototype
|
|
296
|
-
const createScaffold = repository.createScaffold
|
|
297
|
-
repository.createScaffold = async function (preset) {
|
|
298
|
-
const result = await createScaffold.call(this, preset)
|
|
299
|
-
if (result.data) result.data.content = SCAFFOLD
|
|
300
|
-
return result
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
const partialViews = UmbPartialViewDetailRepository.prototype
|
|
304
|
-
const createPartialViewScaffold = partialViews.createScaffold
|
|
305
|
-
partialViews.createScaffold = async function (preset) {
|
|
306
|
-
const result = await createPartialViewScaffold.call(this, preset)
|
|
307
|
-
// Started from a snippet it has content already; empty, it gets the skeleton
|
|
308
|
-
if (result.data && !result.data.content) {
|
|
309
|
-
const { data } = await PartialViewService.getPartialViewSnippetById({ path: { id: 'Empty' } })
|
|
310
|
-
if (data?.content) result.data.content = data.content
|
|
311
|
-
}
|
|
312
|
-
return result
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
// The workspace context is not exported; it is the module beside the package's
|
|
316
|
-
// entry, which the import map resolves to the very module Umbraco loads
|
|
317
|
-
const { UmbTemplateWorkspaceContext } = await import(
|
|
318
|
-
new URL(
|
|
319
|
-
'./workspace/template-workspace.context.js',
|
|
320
|
-
import.meta.resolve('@umbraco-cms/backoffice/template'),
|
|
321
|
-
).href
|
|
322
|
-
)
|
|
323
|
-
const workspace = UmbTemplateWorkspaceContext.prototype
|
|
324
|
-
const setLayoutTemplate = workspace.setLayoutTemplate
|
|
325
|
-
workspace.setLayoutTemplate = async function (unique, updateLayoutBlock) {
|
|
326
|
-
// Umbraco's own update writes Razor; the state it keeps is what we want
|
|
327
|
-
await setLayoutTemplate.call(this, unique, false)
|
|
328
|
-
if (!updateLayoutBlock) return unique
|
|
329
|
-
const items = unique ? (await this.itemRepository.requestItems([unique])).data : []
|
|
330
|
-
const content = this._data.getCurrent()?.content ?? ''
|
|
331
|
-
this._data.updateCurrent({
|
|
332
|
-
content: withLayout(content, items?.[0]?.alias ?? null),
|
|
333
|
-
layoutTemplate: unique ? { unique } : null,
|
|
334
|
-
})
|
|
335
|
-
return unique
|
|
336
|
-
}
|
|
227
|
+
const { umbCromboloHooks } = await import('@umbraco-cms/backoffice/extension-registry')
|
|
228
|
+
Object.assign(umbCromboloHooks, TSX_HOOKS)
|
|
337
229
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "../../backoffice-dist/dist/umbraco-package-schema.json",
|
|
3
3
|
"name": "Crombolo",
|
|
4
4
|
"id": "Crombolo.Core",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.42.1",
|
|
6
6
|
"allowPublicAccess": false,
|
|
7
7
|
"extensions": [
|
|
8
8
|
{
|
|
@@ -510,12 +510,6 @@
|
|
|
510
510
|
}
|
|
511
511
|
]
|
|
512
512
|
},
|
|
513
|
-
{
|
|
514
|
-
"type": "backofficeEntryPoint",
|
|
515
|
-
"alias": "Crombolo.EntryPoint.Branding",
|
|
516
|
-
"name": "Crombolo Branding",
|
|
517
|
-
"js": "/crombolo-plugin/branding/branding.js"
|
|
518
|
-
},
|
|
519
513
|
{
|
|
520
514
|
"type": "backofficeEntryPoint",
|
|
521
515
|
"alias": "Crombolo.EntryPoint.HelpMenu",
|
|
@@ -588,12 +582,6 @@
|
|
|
588
582
|
"propertyEditorSchemaAlias": "Crombolo.FormPicker"
|
|
589
583
|
}
|
|
590
584
|
},
|
|
591
|
-
{
|
|
592
|
-
"type": "backofficeEntryPoint",
|
|
593
|
-
"alias": "Crombolo.EntryPoint.ClientCredentials",
|
|
594
|
-
"name": "Crombolo Client Credential Prefix",
|
|
595
|
-
"js": "/crombolo-plugin/branding/client-credentials.js"
|
|
596
|
-
},
|
|
597
585
|
{
|
|
598
586
|
"type": "backofficeEntryPoint",
|
|
599
587
|
"alias": "Crombolo.EntryPoint.ComponentsTree",
|
|
@@ -606,24 +594,12 @@
|
|
|
606
594
|
"name": "Crombolo Content Type Labels",
|
|
607
595
|
"js": "/crombolo-plugin/branding/content-type-labels.js"
|
|
608
596
|
},
|
|
609
|
-
{
|
|
610
|
-
"type": "backofficeEntryPoint",
|
|
611
|
-
"alias": "Crombolo.EntryPoint.QueryBuilder",
|
|
612
|
-
"name": "Crombolo Query Builder Language",
|
|
613
|
-
"js": "/crombolo-plugin/branding/query-builder.js"
|
|
614
|
-
},
|
|
615
597
|
{
|
|
616
598
|
"type": "backofficeEntryPoint",
|
|
617
599
|
"alias": "Crombolo.EntryPoint.SignIn",
|
|
618
600
|
"name": "Crombolo Sign-in Button",
|
|
619
601
|
"js": "/crombolo-plugin/branding/sign-in.js"
|
|
620
602
|
},
|
|
621
|
-
{
|
|
622
|
-
"type": "backofficeEntryPoint",
|
|
623
|
-
"alias": "Crombolo.EntryPoint.LogViewerMenu",
|
|
624
|
-
"name": "Crombolo Log Viewer Search Menu",
|
|
625
|
-
"js": "/crombolo-plugin/branding/log-viewer-menu.js"
|
|
626
|
-
},
|
|
627
603
|
{
|
|
628
604
|
"type": "backofficeEntryPoint",
|
|
629
605
|
"alias": "Crombolo.EntryPoint.NotificationsDialog",
|
|
@@ -709,7 +685,7 @@
|
|
|
709
685
|
"alias": "Crombolo.SectionView.Workflow.Designer",
|
|
710
686
|
"name": "Crombolo Workflow Designer",
|
|
711
687
|
"element": "/crombolo-plugin/workflow-designer.js",
|
|
712
|
-
"weight":
|
|
688
|
+
"weight": 500,
|
|
713
689
|
"meta": {
|
|
714
690
|
"label": "Workflows",
|
|
715
691
|
"pathname": "workflows",
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The two places the vendored client names the product in code rather than in a
|
|
3
|
-
* string table.
|
|
4
|
-
*
|
|
5
|
-
* `view.controller.js` builds the page title with a hardcoded suffix, which
|
|
6
|
-
* `vendor:backoffice` rebrands to Crombolo. The suffix should be the site's own
|
|
7
|
-
* name, which the shell states in `<meta name="application-name">` — so a site
|
|
8
|
-
* called something other than Crombolo gets its own name rather than ours.
|
|
9
|
-
*
|
|
10
|
-
* Not read from `document.title`, although the shell puts the name there too.
|
|
11
|
-
* This module loads after the client has started, and by then the client may
|
|
12
|
-
* have written a title of its own. Taking `Content | Crombolo` for the site's
|
|
13
|
-
* name makes every correction end in ` | Crombolo` again: the observer below
|
|
14
|
-
* then answers its own change, forever, and the page never gets its main thread
|
|
15
|
-
* back.
|
|
16
|
-
*/
|
|
17
|
-
const CLIENT_SUFFIX = ' | Crombolo'
|
|
18
|
-
|
|
19
|
-
/** The site's name as the shell stated it. */
|
|
20
|
-
export function brandName(doc = document) {
|
|
21
|
-
const stated = doc.querySelector('meta[name="application-name"]')?.getAttribute('content')
|
|
22
|
-
return stated?.trim() || 'Crombolo'
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* `title` with the client's suffix replaced by the site's name.
|
|
27
|
-
*
|
|
28
|
-
* A fixed point: its own output comes back unchanged, whatever the name is —
|
|
29
|
-
* including a name that itself ends in the client's suffix. That is what makes
|
|
30
|
-
* it safe to call from an observer of the very thing it writes.
|
|
31
|
-
*/
|
|
32
|
-
export function brandedTitle(title, brand) {
|
|
33
|
-
const branded = ` | ${brand}`
|
|
34
|
-
if (title.endsWith(branded) || !title.endsWith(CLIENT_SUFFIX)) return title
|
|
35
|
-
return `${title.slice(0, -CLIENT_SUFFIX.length)}${branded}`
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* The logo popover carries a link to umbraco.com, hardcoded in
|
|
40
|
-
* `backoffice-header-logo.element.js`. Its image is already served as crombolo's
|
|
41
|
-
* (see `graphics.ts`), so only the link is left.
|
|
42
|
-
*
|
|
43
|
-
* This reaches into a vendored element's shadow root, which is worth naming as
|
|
44
|
-
* the compromise it is: there is no extension point for the app shell's own
|
|
45
|
-
* chrome. It is written to do nothing at all if that element or its anchor is not
|
|
46
|
-
* what it was, so an upstream change costs a stale link and never an error.
|
|
47
|
-
*/
|
|
48
|
-
function deepQuery(selector, root = document) {
|
|
49
|
-
const direct = root.querySelector(selector)
|
|
50
|
-
if (direct) return direct
|
|
51
|
-
// The header logo lives inside the header's shadow root, so a plain
|
|
52
|
-
// `document.querySelector` cannot see it. Nothing here is reachable without
|
|
53
|
-
// walking through the roots.
|
|
54
|
-
for (const element of root.querySelectorAll('*')) {
|
|
55
|
-
if (!element.shadowRoot) continue
|
|
56
|
-
const found = deepQuery(selector, element.shadowRoot)
|
|
57
|
-
if (found) return found
|
|
58
|
-
}
|
|
59
|
-
return null
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function correctLogoLink() {
|
|
63
|
-
const logo = deepQuery('umb-backoffice-header-logo')
|
|
64
|
-
const anchor = logo?.shadowRoot?.querySelector('a[href*="umbraco.com"]')
|
|
65
|
-
if (!anchor) return false
|
|
66
|
-
anchor.href = 'https://github.com/kineco-au/crombolo-cms'
|
|
67
|
-
anchor.textContent = 'Crombolo on GitHub'
|
|
68
|
-
const image = logo.shadowRoot.querySelector('img#logo')
|
|
69
|
-
if (image) image.alt = brandName()
|
|
70
|
-
return true
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/** Where Umbraco's theme context keeps the choice, as the shells' early script reads it. */
|
|
74
|
-
const THEME_KEY = 'umb-theme-alias'
|
|
75
|
-
|
|
76
|
-
/** Whether a theme choice paints the back office dark: Dark, or Match my system on a dark computer. */
|
|
77
|
-
export function isDarkTheme(alias, prefersDark) {
|
|
78
|
-
return (
|
|
79
|
-
alias === 'Crombolo.Theme.Dark' ||
|
|
80
|
-
alias === 'umb-dark-theme' ||
|
|
81
|
-
(alias === 'Crombolo.Theme.System' && Boolean(prefersDark))
|
|
82
|
-
)
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const GRAPHIC =
|
|
86
|
-
/(\/security\/back-office\/graphics\/)(logo|logo-alternative|login-logo|login-logo-alternative)(-dark)?$/
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* A logo's address for the theme: the cream-lettered `-dark` variant on a dark
|
|
90
|
-
* theme, the plain one otherwise. Anything that is not one of the logos comes
|
|
91
|
-
* back as it was.
|
|
92
|
-
*/
|
|
93
|
-
export function themedLogoUrl(src, dark) {
|
|
94
|
-
const match = GRAPHIC.exec(src ?? '')
|
|
95
|
-
if (!match) return src
|
|
96
|
-
return `${src.slice(0, match.index)}${match[1]}${match[2]}${dark ? '-dark' : ''}`
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const prefersDark = () => {
|
|
100
|
-
try {
|
|
101
|
-
return window.matchMedia('(prefers-color-scheme: dark)').matches
|
|
102
|
-
} catch {
|
|
103
|
-
return false
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const storedTheme = () => {
|
|
108
|
-
try {
|
|
109
|
-
return localStorage.getItem(THEME_KEY)
|
|
110
|
-
} catch {
|
|
111
|
-
return null
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* The header's logo, and the wordmark in its popover, in the theme's colours.
|
|
117
|
-
*
|
|
118
|
-
* `umb-app-logo` picks its graphic from Umbraco's own theme names, and the
|
|
119
|
-
* header pins it to the one drawn for an orange bar, so its cocoa lettering
|
|
120
|
-
* vanished on the dark header. Like the link above, this reaches into the
|
|
121
|
-
* vendored element and does nothing if it is not what it was.
|
|
122
|
-
*/
|
|
123
|
-
function applyThemedLogos() {
|
|
124
|
-
const dark = isDarkTheme(storedTheme(), prefersDark())
|
|
125
|
-
const header = deepQuery('umb-backoffice-header-logo')?.shadowRoot
|
|
126
|
-
const mark = header?.querySelector('umb-app-logo')?.shadowRoot?.querySelector('img')
|
|
127
|
-
if (!mark) return false
|
|
128
|
-
const src = mark.getAttribute('src')
|
|
129
|
-
const next = themedLogoUrl(src, dark)
|
|
130
|
-
if (next !== src) mark.setAttribute('src', next)
|
|
131
|
-
const popover = header.querySelector('img#logo')
|
|
132
|
-
if (popover) {
|
|
133
|
-
popover.dataset.lightSrc ??= popover.getAttribute('src') ?? ''
|
|
134
|
-
const wanted = dark
|
|
135
|
-
? next.replace(/graphics\/logo-dark$/, 'graphics/logo-alternative-dark')
|
|
136
|
-
: popover.dataset.lightSrc
|
|
137
|
-
if (popover.getAttribute('src') !== wanted) popover.setAttribute('src', wanted)
|
|
138
|
-
}
|
|
139
|
-
return true
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/** Applies the logos now and on every change of theme: the menu, another tab, or the computer's. */
|
|
143
|
-
function followTheme() {
|
|
144
|
-
const apply = () => setTimeout(applyThemedLogos, 0)
|
|
145
|
-
// The theme context swaps the theme's stylesheet in the head when the choice changes.
|
|
146
|
-
new MutationObserver(apply).observe(document.head, { childList: true })
|
|
147
|
-
window.addEventListener('storage', (event) => {
|
|
148
|
-
if (event.key === THEME_KEY) apply()
|
|
149
|
-
})
|
|
150
|
-
try {
|
|
151
|
-
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', apply)
|
|
152
|
-
} catch {
|
|
153
|
-
// Without media queries, Match my system stays light.
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
export const onInit = () => {
|
|
158
|
-
const brand = brandName()
|
|
159
|
-
let themed = false
|
|
160
|
-
const logos = setInterval(() => {
|
|
161
|
-
if (applyThemedLogos() && !themed) {
|
|
162
|
-
themed = true
|
|
163
|
-
clearInterval(logos)
|
|
164
|
-
followTheme()
|
|
165
|
-
}
|
|
166
|
-
}, 250)
|
|
167
|
-
setTimeout(() => clearInterval(logos), 30_000)
|
|
168
|
-
const correct = () => {
|
|
169
|
-
const corrected = brandedTitle(document.title, brand)
|
|
170
|
-
if (corrected !== document.title) document.title = corrected
|
|
171
|
-
}
|
|
172
|
-
correct()
|
|
173
|
-
// The header renders after the app boots, and the popover's contents with it.
|
|
174
|
-
let tries = 0
|
|
175
|
-
const timer = setInterval(() => {
|
|
176
|
-
if (correctLogoLink() || ++tries > 40) clearInterval(timer)
|
|
177
|
-
}, 250)
|
|
178
|
-
const head = document.querySelector('head')
|
|
179
|
-
const title = document.querySelector('title')
|
|
180
|
-
if (!head || !title) return
|
|
181
|
-
// The element is replaced as well as retitled, so both are watched.
|
|
182
|
-
new MutationObserver(correct).observe(title, {
|
|
183
|
-
childList: true,
|
|
184
|
-
characterData: true,
|
|
185
|
-
subtree: true,
|
|
186
|
-
})
|
|
187
|
-
new MutationObserver(correct).observe(head, { childList: true })
|
|
188
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The prefix label in the Create client credential dialog.
|
|
3
|
-
*
|
|
4
|
-
* The dialog prints the required prefix in a decorative `prepend` beside the Id
|
|
5
|
-
* input, and submits the input's value whole — so an administrator reads that
|
|
6
|
-
* label and types the prefix themselves. It is hardcoded in the vendored element
|
|
7
|
-
* as a private field, and it names the prefix the server rejected as of
|
|
8
|
-
* migration 020, which makes a stale label a dialog nobody can complete.
|
|
9
|
-
*
|
|
10
|
-
* Corrected after the element's first render rather than in its template: the
|
|
11
|
-
* prepend is built inside a private method, so there is nothing to intercept
|
|
12
|
-
* further upstream.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
/** Must match `CLIENT_ID_PREFIX` in packages/server/src/adapters/users.ts. */
|
|
16
|
-
export const REQUIRED_PREFIX = 'crombolo-back-office-'
|
|
17
|
-
|
|
18
|
-
/** True for the vendored label, and false for anything a correction produced. */
|
|
19
|
-
export function needsCorrection(text) {
|
|
20
|
-
return typeof text === 'string' && text.trim() === 'umbraco-back-office-'
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function correct(root) {
|
|
24
|
-
const prepend = root?.querySelector('.prepend')
|
|
25
|
-
if (prepend && needsCorrection(prepend.textContent)) prepend.textContent = REQUIRED_PREFIX
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Wraps the element's own `firstUpdated`, which the vendored class defines and
|
|
30
|
-
* which runs once the prepend exists. Does nothing if it is not there, so an
|
|
31
|
-
* upstream change costs the correction and never an error.
|
|
32
|
-
*/
|
|
33
|
-
function patch(element) {
|
|
34
|
-
const proto = element?.prototype
|
|
35
|
-
const original = proto?.firstUpdated
|
|
36
|
-
if (typeof original !== 'function') return false
|
|
37
|
-
proto.firstUpdated = function firstUpdated(changed) {
|
|
38
|
-
original.call(this, changed)
|
|
39
|
-
correct(this.shadowRoot)
|
|
40
|
-
}
|
|
41
|
-
return true
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export const onInit = () => {
|
|
45
|
-
customElements
|
|
46
|
-
.whenDefined('umb-create-user-client-credential-modal')
|
|
47
|
-
.then(patch)
|
|
48
|
-
.catch(() => {})
|
|
49
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The search menu on a log message, pointed at this project rather than at
|
|
3
|
-
* Umbraco's.
|
|
4
|
-
*
|
|
5
|
-
* `log-viewer-message.element.js` builds six items in `_getSearchMenuData()`,
|
|
6
|
-
* four of them Umbraco's: two that search the Umbraco forum — one under the
|
|
7
|
-
* Umbraco mark — and two that search Umbraco-CMS on GitHub by the line's
|
|
8
|
-
* `SourceContext`. The forum pair goes, because there is no crombolo forum to
|
|
9
|
-
* send anyone to and the item above it already puts the message into Google.
|
|
10
|
-
* The GitHub pair stays, repointed: searching the source and the issues by the
|
|
11
|
-
* type that logged a line is how you chase one down, it just has to be this
|
|
12
|
-
* CMS's source and issues.
|
|
13
|
-
*
|
|
14
|
-
* The array is rebuilt on every render by a method on the element's prototype,
|
|
15
|
-
* so the method is wrapped rather than the element replaced: the rest of the
|
|
16
|
-
* log viewer is what we want, and wrapping keeps the two items we leave alone —
|
|
17
|
-
* and anything upstream adds — exactly as they were.
|
|
18
|
-
*
|
|
19
|
-
* Items are matched on their **resolved** label rather than the key, because
|
|
20
|
-
* the key is not readable off the built array: `localize.term` returns the
|
|
21
|
-
* string. Resolving the same keys through the same controller matches in
|
|
22
|
-
* whatever language the editor is in.
|
|
23
|
-
*
|
|
24
|
-
* Patched rather than registered, because the menu is not an extension point.
|
|
25
|
-
*/
|
|
26
|
-
const TAG = 'umb-log-viewer-message'
|
|
27
|
-
export const REPOSITORY = 'https://github.com/kineco-au/crombolo-cms'
|
|
28
|
-
|
|
29
|
-
/** The forum pair, which has no equivalent here. */
|
|
30
|
-
export const DROPPED = ['logViewer_searchOurUmbraco', 'logViewer_searchOurUmbracoWithGoogle']
|
|
31
|
-
|
|
32
|
-
/** The GitHub pair, whose labels we keep and whose targets we replace. */
|
|
33
|
-
export const REPOINTED = {
|
|
34
|
-
logViewer_searchUmbracoSource: (query) => `${REPOSITORY}/search?q=${query}`,
|
|
35
|
-
logViewer_searchUmbracoIssues: (query) => `${REPOSITORY}/issues?q=${query}`,
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* `items` with Umbraco's forum entries gone and its GitHub entries aimed here.
|
|
40
|
-
*
|
|
41
|
-
* `term` resolves a dictionary key the way the element does, so this matches
|
|
42
|
-
* the labels in the editor's own language; `query` is the `SourceContext` the
|
|
43
|
-
* two surviving searches look for.
|
|
44
|
-
*/
|
|
45
|
-
export function rebrandSearchMenu(items, term, query) {
|
|
46
|
-
const dropped = new Set(DROPPED.map(term))
|
|
47
|
-
const repointed = new Map(
|
|
48
|
-
Object.entries(REPOINTED).map(([key, href]) => [term(key), () => href(query)]),
|
|
49
|
-
)
|
|
50
|
-
return items
|
|
51
|
-
.filter((item) => !dropped.has(item.label))
|
|
52
|
-
.map((item) => {
|
|
53
|
-
const href = repointed.get(item.label)
|
|
54
|
-
return href ? { ...item, href } : item
|
|
55
|
-
})
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export const onInit = async () => {
|
|
59
|
-
// Registered with the Log Viewer section, so not defined until it is opened.
|
|
60
|
-
const element = await customElements.whenDefined(TAG)
|
|
61
|
-
const prototype = element.prototype
|
|
62
|
-
const original = prototype._getSearchMenuData
|
|
63
|
-
if (typeof original !== 'function') return
|
|
64
|
-
|
|
65
|
-
prototype._getSearchMenuData = function patched() {
|
|
66
|
-
const query =
|
|
67
|
-
this.properties?.find((property) => property.name === 'SourceContext')?.value ?? ''
|
|
68
|
-
return rebrandSearchMenu(original.call(this), (key) => this.localize.term(key), query)
|
|
69
|
-
}
|
|
70
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The template editor's query builder writes TypeScript, so it should not say
|
|
3
|
-
* it wrote C#.
|
|
4
|
-
*
|
|
5
|
-
* The modal hard-codes `language="C#"` on the code block it previews the
|
|
6
|
-
* snippet in (`query-builder-modal.element.js`). The element is vendored, so
|
|
7
|
-
* the label is corrected after each render rather than by replacing the modal:
|
|
8
|
-
* the rest of it — the pickers, the filters, the sample results — is exactly
|
|
9
|
-
* what we want, and a fork of it would be a fork to maintain.
|
|
10
|
-
*/
|
|
11
|
-
const TAG = 'umb-template-query-builder-modal'
|
|
12
|
-
const LANGUAGE = 'TypeScript'
|
|
13
|
-
|
|
14
|
-
export const onInit = async () => {
|
|
15
|
-
// The modal is registered lazily, so the class may not be defined until the
|
|
16
|
-
// editor opens it.
|
|
17
|
-
const element = await customElements.whenDefined(TAG)
|
|
18
|
-
const prototype = element.prototype
|
|
19
|
-
const updated = prototype.updated
|
|
20
|
-
prototype.updated = function patched(changed) {
|
|
21
|
-
updated?.call(this, changed)
|
|
22
|
-
const block = this.shadowRoot?.querySelector('umb-code-block')
|
|
23
|
-
if (block && block.getAttribute('language') !== LANGUAGE) {
|
|
24
|
-
block.setAttribute('language', LANGUAGE)
|
|
25
|
-
block.language = LANGUAGE
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|