actions
This commit is contained in:
@@ -8,10 +8,12 @@ import { UmbHealthCheckDashboardContext } from '../health-check-dashboard.contex
|
||||
import {
|
||||
HealthCheckAction,
|
||||
HealthCheckGroupWithResult,
|
||||
HealthCheckResource,
|
||||
HealthCheckWithResult,
|
||||
StatusResultType,
|
||||
} from '@umbraco-cms/backend-api';
|
||||
import { UmbLitElement } from '@umbraco-cms/element';
|
||||
import { tryExecuteAndNotify } from '@umbraco-cms/resources';
|
||||
|
||||
@customElement('umb-dashboard-health-check-group')
|
||||
export class UmbDashboardHealthCheckGroupElement extends UmbLitElement {
|
||||
@@ -113,6 +115,9 @@ export class UmbDashboardHealthCheckGroupElement extends UmbLitElement {
|
||||
@state()
|
||||
private _keyResults?: any;
|
||||
|
||||
@state()
|
||||
private _actionButtonStates?: [{ key: string; state: UUIButtonState }];
|
||||
|
||||
private _api?: UmbHealthCheckContext;
|
||||
|
||||
constructor() {
|
||||
@@ -141,6 +146,10 @@ export class UmbDashboardHealthCheckGroupElement extends UmbLitElement {
|
||||
this._buttonState = 'success';
|
||||
}
|
||||
|
||||
private async _onActionClick(action: HealthCheckAction) {
|
||||
await tryExecuteAndNotify(this, HealthCheckResource.postHealthCheckExecuteAction({ requestBody: action }));
|
||||
}
|
||||
|
||||
render() {
|
||||
if (this._group) {
|
||||
return html`
|
||||
@@ -185,6 +194,7 @@ export class UmbDashboardHealthCheckGroupElement extends UmbLitElement {
|
||||
<uui-icon name="umb:out"></uui-icon>
|
||||
</uui-button>`
|
||||
: nothing}
|
||||
${result.actions ? this.renderActions(result.actions) : nothing}
|
||||
</div>`;
|
||||
})}
|
||||
</div>
|
||||
@@ -211,7 +221,11 @@ export class UmbDashboardHealthCheckGroupElement extends UmbLitElement {
|
||||
return html` <div class="action-wrapper">
|
||||
${actions.map((action) => {
|
||||
return html` <div class="action">
|
||||
<uui-button look="primary" color="positive" label="${action.name || 'action'}">
|
||||
<uui-button
|
||||
look="primary"
|
||||
color="positive"
|
||||
label="${action.name || 'action'}"
|
||||
@click="${() => this._onActionClick(action)}">
|
||||
${action.name || 'Action'}
|
||||
</uui-button>
|
||||
<p>${action.description || html`<span class="no-description">This action has no description</span>`}</p>
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
HealthCheckWithResult,
|
||||
HealthCheckResult,
|
||||
StatusResultType,
|
||||
HealthCheckAction,
|
||||
} from '@umbraco-cms/backend-api';
|
||||
|
||||
export function getGroupByName(name: string) {
|
||||
@@ -28,6 +29,14 @@ export const healthGroups: HealthCheckGroupWithResult[] = [
|
||||
completely if there are any errors in macros. Rectifying this will set the value to 'Inline'. `,
|
||||
resultType: StatusResultType.ERROR,
|
||||
readMoreLink: 'https://umbra.co/healthchecks-macro-errors',
|
||||
actions: [
|
||||
{
|
||||
healthCheckKey: 'key123',
|
||||
name: 'Action name',
|
||||
alias: 'Action alias',
|
||||
description: 'Action description',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -28,105 +28,11 @@ export const handlers = [
|
||||
}
|
||||
}),
|
||||
|
||||
rest.post(umbracoPath('/postHealthCheckExecuteAction'), async (_req, res, ctx) => {
|
||||
rest.post(umbracoPath('/health-check/execute-action'), async (_req, res, ctx) => {
|
||||
await new Promise((resolve) => setTimeout(resolve, (Math.random() + 1) * 1000)); // simulate a delay of 1-2 seconds
|
||||
return res(
|
||||
// Respond with a 200 status code
|
||||
ctx.status(200)
|
||||
);
|
||||
}),
|
||||
|
||||
rest.get(umbracoPath('/health-check/security'), (_req, res, ctx) => {
|
||||
return res(
|
||||
ctx.status(200),
|
||||
ctx.json<any>([
|
||||
{
|
||||
alias: 'applicationUrlConfiguration',
|
||||
results: [
|
||||
{
|
||||
message: `The appSetting 'Umbraco:CMS:WebRouting:UmbracoApplicationUrl' is not set`,
|
||||
resultType: StatusResultType.WARNING,
|
||||
readMoreLink: 'https://umbra.co/healthchecks-umbraco-application-url',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
alias: 'clickJackingProtection',
|
||||
results: [
|
||||
{
|
||||
message: `Error pinging the URL https://localhost:44361 - 'The SSL connection could not be established,
|
||||
see inner exception.'`,
|
||||
resultType: StatusResultType.ERROR,
|
||||
readMoreLink: 'https://umbra.co/healthchecks-click-jacking',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
alias: 'contentSniffingProtection',
|
||||
results: [
|
||||
{
|
||||
message: `Error pinging the URL https://localhost:44361 - 'The SSL connection could not be established,
|
||||
see inner exception.'`,
|
||||
resultType: StatusResultType.ERROR,
|
||||
readMoreLink: 'https://umbra.co/healthchecks-no-sniff',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
alias: 'cookieHijackingProtection',
|
||||
results: [
|
||||
{
|
||||
message: `Error pinging the URL https://localhost:44361 - 'The SSL connection could not be established,
|
||||
see inner exception.'`,
|
||||
resultType: StatusResultType.ERROR,
|
||||
readMoreLink: 'https://umbra.co/healthchecks-hsts',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
alias: 'crossSiteProtection',
|
||||
results: [
|
||||
{
|
||||
message: `Error pinging the URL https://localhost:44361 - 'The SSL connection could not be established,
|
||||
see inner exception.'`,
|
||||
resultType: StatusResultType.ERROR,
|
||||
readMoreLink: 'https://umbra.co/healthchecks-xss-protection',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
alias: 'excessiveHeaders',
|
||||
results: [
|
||||
{
|
||||
message: `Error pinging the URL https://localhost:44361 - 'The SSL connection could not be established,
|
||||
see inner exception.'`,
|
||||
resultType: StatusResultType.WARNING,
|
||||
readMoreLink: 'https://umbra.co/healthchecks-excessive-headers',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
alias: 'HttpsConfiguration',
|
||||
results: [
|
||||
{
|
||||
message: `You are currently viewing the site using HTTPS scheme`,
|
||||
resultType: StatusResultType.SUCCESS,
|
||||
},
|
||||
{
|
||||
message: `The appSetting 'Umbraco:CMS:Global:UseHttps' is set to 'False' in your appSettings.json file,
|
||||
your cookies are not marked as secure.`,
|
||||
resultType: StatusResultType.ERROR,
|
||||
readMoreLink: 'https://umbra.co/healthchecks-https-config',
|
||||
},
|
||||
{
|
||||
message: `Error pinging the URL https://localhost:44361/ - 'The SSL connection could not be established,
|
||||
see inner exception.'"`,
|
||||
resultType: StatusResultType.ERROR,
|
||||
readMoreLink: 'https://umbra.co/healthchecks-https-request',
|
||||
},
|
||||
],
|
||||
},
|
||||
])
|
||||
);
|
||||
}),
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user