clean up
This commit is contained in:
@@ -31,16 +31,14 @@ export class UmbDashboardHealthCheckElement extends UmbLitElement {
|
||||
},
|
||||
];
|
||||
|
||||
private _healthCheckManifests: ManifestHealthCheck[] = [];
|
||||
private _healthCheckDashboardContext = new UmbHealthCheckDashboardContext(this);
|
||||
|
||||
connectedCallback(): void {
|
||||
super.connectedCallback();
|
||||
umbExtensionsRegistry.extensionsOfType('healthCheck').subscribe((healthChecks) => {
|
||||
this._healthCheckManifests = healthChecks;
|
||||
this.provideContext(
|
||||
UMB_HEALTHCHECK_DASHBOARD_CONTEXT_TOKEN,
|
||||
new UmbHealthCheckDashboardContext(this, this._healthCheckManifests)
|
||||
);
|
||||
constructor() {
|
||||
super();
|
||||
this.provideContext(UMB_HEALTHCHECK_DASHBOARD_CONTEXT_TOKEN, this._healthCheckDashboardContext);
|
||||
|
||||
this.observe(umbExtensionsRegistry.extensionsOfType('healthCheck'), (healthCheckManifests) => {
|
||||
this._healthCheckDashboardContext.manifests = healthCheckManifests;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -3,24 +3,35 @@ import type { ManifestHealthCheck } from '@umbraco-cms/models';
|
||||
import { UmbContextToken } from '@umbraco-cms/context-api';
|
||||
|
||||
export class UmbHealthCheckDashboardContext {
|
||||
public manifests: ManifestHealthCheck[] = [];
|
||||
#manifests: ManifestHealthCheck[] = [];
|
||||
set manifests(value: ManifestHealthCheck[]) {
|
||||
this.#manifests = value;
|
||||
this.#registerApis();
|
||||
}
|
||||
get manifests() {
|
||||
return this.#manifests;
|
||||
}
|
||||
|
||||
public apis = new Map<string, UmbHealthCheckContext>();
|
||||
public host: any;
|
||||
public host: HTMLElement;
|
||||
|
||||
constructor(host: any, manifests: Array<ManifestHealthCheck>) {
|
||||
this.manifests = manifests;
|
||||
constructor(host: HTMLElement) {
|
||||
this.host = host;
|
||||
|
||||
this.manifests.forEach((manifest) => {
|
||||
this.apis.set(manifest.meta.label, new manifest.meta.api(this.host));
|
||||
});
|
||||
}
|
||||
|
||||
checkAll() {
|
||||
for (const [label, api] of this.apis.entries()) {
|
||||
api.checkGroup(label);
|
||||
api?.checkGroup?.(label);
|
||||
}
|
||||
}
|
||||
|
||||
#registerApis() {
|
||||
this.apis.clear();
|
||||
this.#manifests.forEach((manifest) => {
|
||||
// the group name (label) is the unique key for a health check group
|
||||
this.apis.set(manifest.meta.label, new manifest.meta.api(this.host));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export const UMB_HEALTHCHECK_DASHBOARD_CONTEXT_TOKEN = new UmbContextToken<UmbHealthCheckDashboardContext>(
|
||||
|
||||
@@ -3,7 +3,10 @@ import { css, html } from 'lit';
|
||||
import { customElement, state } from 'lit/decorators.js';
|
||||
import { UUIButtonState } from '@umbraco-ui/uui';
|
||||
|
||||
import { UmbHealthCheckDashboardContext } from '../health-check-dashboard.context';
|
||||
import {
|
||||
UmbHealthCheckDashboardContext,
|
||||
UMB_HEALTHCHECK_DASHBOARD_CONTEXT_TOKEN,
|
||||
} from '../health-check-dashboard.context';
|
||||
import { UmbLitElement } from '@umbraco-cms/element';
|
||||
|
||||
import { ManifestHealthCheck } from '@umbraco-cms/extensions-registry';
|
||||
@@ -30,24 +33,15 @@ export class UmbDashboardHealthCheckOverviewElement extends UmbLitElement {
|
||||
@state()
|
||||
private _buttonState: UUIButtonState;
|
||||
|
||||
private _healthCheckManifests: ManifestHealthCheck[] = [];
|
||||
|
||||
private _healthCheckDashboardContext?: UmbHealthCheckDashboardContext;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.consumeContext('umbHealthCheckDashboard', (instance: UmbHealthCheckDashboardContext) => {
|
||||
this.consumeContext(UMB_HEALTHCHECK_DASHBOARD_CONTEXT_TOKEN, (instance) => {
|
||||
this._healthCheckDashboardContext = instance;
|
||||
});
|
||||
}
|
||||
|
||||
connectedCallback(): void {
|
||||
super.connectedCallback();
|
||||
umbExtensionsRegistry.extensionsOfType('healthCheck').subscribe((healthChecks) => {
|
||||
this._healthCheckManifests = healthChecks;
|
||||
});
|
||||
}
|
||||
|
||||
private async _onHealthCheckHandler() {
|
||||
this._healthCheckDashboardContext?.checkAll();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user