@crombolo/backoffice-host 0.40.0 → 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.
Files changed (35) hide show
  1. package/package.json +3 -3
  2. package/plugin/addresses-dashboard.js +3 -2
  3. package/plugin/app-preview/umbraco-package.json +1 -1
  4. package/plugin/audit-dashboard.js +3 -2
  5. package/plugin/branding/localization-en.js +9 -3
  6. package/plugin/branding/sign-in.js +0 -31
  7. package/plugin/bundle-editor-code.js +2 -0
  8. package/plugin/bundle-editor-content.js +2 -0
  9. package/plugin/bundle-editor-context.js +95 -0
  10. package/plugin/bundle-editor-forms.js +2 -0
  11. package/plugin/bundle-editor-language.js +2 -0
  12. package/plugin/bundle-editor-routing.js +13 -0
  13. package/plugin/bundle-editor-sections.js +389 -0
  14. package/plugin/bundle-editor-types.js +2 -0
  15. package/plugin/bundle-editor-user-groups.js +2 -0
  16. package/plugin/bundle-editor-workflows.js +2 -0
  17. package/plugin/bundle-editor.js +140 -0
  18. package/plugin/bundles-client.js +12 -0
  19. package/plugin/bundles-created.js +2 -1
  20. package/plugin/changes-dashboard.js +3 -2
  21. package/plugin/edit-conflicts.js +11 -21
  22. package/plugin/jobs-dashboard.js +3 -2
  23. package/plugin/localizations/umbraco-package.json +1 -1
  24. package/plugin/notifications-dialog.js +8 -35
  25. package/plugin/seo/umbraco-package.json +1 -1
  26. package/plugin/side-panel/host.js +7 -63
  27. package/plugin/side-panel/layout.js +0 -15
  28. package/plugin/sign-in/umbraco-package.json +1 -1
  29. package/plugin/tsx-editors.js +56 -164
  30. package/plugin/umbraco-package.json +138 -32
  31. package/plugin/branding/branding.js +0 -188
  32. package/plugin/branding/bundle-builder-labels.js +0 -92
  33. package/plugin/branding/client-credentials.js +0 -49
  34. package/plugin/branding/log-viewer-menu.js +0 -70
  35. package/plugin/branding/query-builder.js +0 -28
@@ -1,92 +0,0 @@
1
- /**
2
- * The two labels and two toasts Umbraco's bundle builder hard-codes.
3
- *
4
- * The builder workspace is vendored and its copy is English in the template
5
- * rather than dictionary keys, so there is no key to override: `Name of the
6
- * package` labels the name input and `Package Content` heads the picker box.
7
- * Everything else in that screen is already a key or a field name.
8
- *
9
- * Corrected after the element's first render, the same way the client
10
- * credential dialog's prefix is, because both strings are written by the
11
- * element's own template and there is nothing further upstream to intercept.
12
- *
13
- * Does nothing if upstream changes either string, so the cost of a vendor bump
14
- * is the correction and never an error — `tests/bundles-backoffice.test.ts`
15
- * asserts both are still there to correct.
16
- */
17
-
18
- /** Vendored text to the text that replaces it. */
19
- export const BUILDER_LABELS = [
20
- ['Name of the package', 'Name of the bundle'],
21
- ['Package Content', 'Bundle content'],
22
- ]
23
-
24
- /**
25
- * The builder's toasts on saving a definition. Shown through the notification
26
- * context, so they are corrected where every toast passes rather than in the
27
- * element, whose `peek` call is its own.
28
- */
29
- export const BUILDER_TOASTS = [
30
- ['Package saved', 'Bundle saved'],
31
- ['Package updated', 'Bundle saved'],
32
- ]
33
-
34
- /** The replacement for a vendored string, or undefined when it is not one of ours. */
35
- export function correctionFor(text) {
36
- if (typeof text !== 'string') return undefined
37
- const trimmed = text.trim()
38
- return BUILDER_LABELS.find(([before]) => before === trimmed)?.[1]
39
- }
40
-
41
- function correct(root) {
42
- const input = root?.querySelector('#package-name-input')
43
- const label = correctionFor(input?.getAttribute('label'))
44
- if (label) input.setAttribute('label', label)
45
-
46
- for (const box of root?.querySelectorAll('uui-box') ?? []) {
47
- const headline = correctionFor(box.getAttribute('headline'))
48
- if (headline) box.setAttribute('headline', headline)
49
- }
50
- }
51
-
52
- /**
53
- * Wraps the element's own `updated`, not `firstUpdated`: the builder renders
54
- * its header before the definition has loaded and fills it in afterwards, so a
55
- * one-shot correction would run against a template that is not there yet.
56
- */
57
- function patch(element) {
58
- const proto = element?.prototype
59
- const original = proto?.updated
60
- if (typeof original !== 'function') return false
61
- proto.updated = function updated(changed) {
62
- original.call(this, changed)
63
- correct(this.shadowRoot)
64
- }
65
- return true
66
- }
67
-
68
- // Loaded here rather than at the top, so the module's pure parts import
69
- // anywhere — the tests read `BUILDER_LABELS` and `BUILDER_TOASTS` outside a browser.
70
- async function correctToasts() {
71
- const { UmbNotificationContext } = await import('@umbraco-cms/backoffice/notification')
72
- const proto = UmbNotificationContext.prototype
73
- const peek = proto.peek
74
- if (typeof peek !== 'function') return
75
- proto.peek = function correctedPeek(color, options) {
76
- const message = options?.data?.message
77
- const replacement = BUILDER_TOASTS.find(([before]) => before === message)?.[1]
78
- return peek.call(
79
- this,
80
- color,
81
- replacement ? { ...options, data: { ...options.data, message: replacement } } : options,
82
- )
83
- }
84
- }
85
-
86
- export const onInit = () => {
87
- correctToasts().catch(() => {})
88
- customElements
89
- .whenDefined('umb-workspace-package-builder')
90
- .then(patch)
91
- .catch(() => {})
92
- }
@@ -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
- }