diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/debug/debug.modal.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/debug/debug.modal.element.ts index b47b026e6c..eed378d006 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/debug/debug.modal.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/debug/debug.modal.element.ts @@ -1,7 +1,7 @@ -import { css, html, nothing, TemplateResult } from 'lit'; -import { customElement, property } from 'lit/decorators.js'; +import { css, html } from 'lit'; +import { customElement } from 'lit/decorators.js'; import { UUITextStyles } from '@umbraco-ui/uui-css'; -import { UmbModalHandler, UmbModalLayoutElement } from '@umbraco-cms/modal'; +import { UmbModalLayoutElement } from '@umbraco-cms/modal'; @customElement('umb-debug-modal-layout') export class UmbDebugModalLayout extends UmbModalLayoutElement { @@ -65,87 +65,12 @@ export class UmbDebugModalLayout extends UmbModalLayoutElement { Debug: Contexts - ${this._renderContextAliases()} + ${this.data.content} Close `; } - - private _renderContextAliases() { - if(!this.data) { - return nothing; - } - - const aliases = []; - for (const [alias, instance] of this.data.contexts) { - aliases.push( - html` -
-

${alias} ${typeof instance}

- ${this._renderInstance(instance)} -
` - ); - } - - return aliases; - } - - private _renderInstance(instance: any) { - const instanceKeys: TemplateResult[] = []; - - if (typeof instance === 'function') { - return instanceKeys.push(html`
  • Callable Function
  • `); - } else if (typeof instance === 'object') { - const methodNames = this.getClassMethodNames(instance); - if (methodNames.length) { - instanceKeys.push( - html` -

    Methods

    - - `); - } - - instanceKeys.push(html`

    Properties

    `); - - for (const key in instance) { - if (key.startsWith('_')) { - continue; - } - - const value = instance[key]; - if (typeof value === 'string') { - instanceKeys.push(html`
  • ${key} = ${value}
  • `); - } else { - instanceKeys.push(html`
  • ${key} Type (${typeof value})
  • `); - } - } - } else { - instanceKeys.push(html`
  • Context is a primitive with value: ${instance}
  • `); - } - - return instanceKeys; - } - - - private getClassMethodNames(klass: any) { - const isGetter = (x: any, name: string): boolean => !!(Object.getOwnPropertyDescriptor(x, name) || {}).get; - const isFunction = (x: any, name: string): boolean => typeof x[name] === 'function'; - const deepFunctions = (x: any): any => - x !== Object.prototype && - Object.getOwnPropertyNames(x) - .filter((name) => isGetter(x, name) || isFunction(x, name)) - .concat(deepFunctions(Object.getPrototypeOf(x)) || []); - const distinctDeepFunctions = (klass: any) => Array.from(new Set(deepFunctions(klass))); - - const allMethods = - typeof klass.prototype === 'undefined' - ? distinctDeepFunctions(klass) - : Object.getOwnPropertyNames(klass.prototype); - return allMethods.filter((name: any) => name !== 'constructor' && !name.startsWith('_')); - } } declare global {