Skip to content

Commit ac522ab

Browse files
authored
Merge pull request #18172 from umbraco/v15/feature/reworking-error-notifications
Feature: reworking error toast notifications
2 parents 9c62160 + db49fb3 commit ac522ab

File tree

24 files changed

+285
-99
lines changed

24 files changed

+285
-99
lines changed

src/Umbraco.Web.UI.Client/src/assets/lang/da-dk.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,8 @@ export default {
584584
deleteLayout: 'You are deleting the layout',
585585
deletingALayout:
586586
'Modifying layout will result in loss of data for any existing content that is based on this configuration.',
587+
seeErrorAction: 'Se fejlen',
588+
seeErrorDialogHeadline: 'Fejl detaljer',
587589
},
588590
dictionary: {
589591
noItems: 'Der er ingen ordbogselementer.',

src/Umbraco.Web.UI.Client/src/assets/lang/en-us.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,8 @@ export default {
614614
deleteLayout: 'You are deleting the layout',
615615
deletingALayout:
616616
'Modifying layout will result in loss of data for any existing content that is based on this configuration.',
617+
seeErrorAction: 'See error',
618+
seeErrorDialogHeadline: 'Error details',
617619
},
618620
dictionary: {
619621
importDictionaryItemHelp:

src/Umbraco.Web.UI.Client/src/assets/lang/en.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,8 @@ export default {
610610
deletingALayout:
611611
'Modifying layout will result in loss of data for any existing content that is based on this configuration.',
612612
selectEditorConfiguration: 'Select configuration',
613+
seeErrorAction: 'See error',
614+
seeErrorDialogHeadline: 'Error details',
613615
},
614616
dictionary: {
615617
importDictionaryItemHelp:

src/Umbraco.Web.UI.Client/src/packages/core/components/code-block/code-block.element.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ export class UmbCodeBlockElement extends LitElement {
6868
}
6969
7070
uui-scroll-container {
71-
max-height: 500px;
7271
overflow-y: auto;
7372
overflow-wrap: anywhere;
7473
}

src/Umbraco.Web.UI.Client/src/packages/core/manifests.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { manifests as iconRegistryManifests } from './icon-registry/manifests.js
1111
import { manifests as localizationManifests } from './localization/manifests.js';
1212
import { manifests as menuManifests } from './menu/manifests.js';
1313
import { manifests as modalManifests } from './modal/manifests.js';
14+
import { manifests as notificationManifests } from './notification/manifests.js';
1415
import { manifests as pickerManifests } from './picker/manifests.js';
1516
import { manifests as propertyActionManifests } from './property-action/manifests.js';
1617
import { manifests as propertyEditorManifests } from './property-editor/manifests.js';
@@ -40,6 +41,7 @@ export const manifests: Array<UmbExtensionManifest | UmbExtensionManifestKind> =
4041
...localizationManifests,
4142
...menuManifests,
4243
...modalManifests,
44+
...notificationManifests,
4345
...pickerManifests,
4446
...propertyActionManifests,
4547
...propertyEditorManifests,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './peek-error.controller.js';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { customElement, html, ifDefined, nothing, property } from '@umbraco-cms/backoffice/external/lit';
2+
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
3+
import type { UmbNotificationHandler } from '../../notification-handler.js';
4+
import { UMB_MODAL_MANAGER_CONTEXT } from '@umbraco-cms/backoffice/modal';
5+
import type { UmbPeekErrorArgs } from '../../types.js';
6+
import { UMB_ERROR_VIEWER_MODAL } from '../../index.js';
7+
8+
@customElement('umb-peek-error-notification')
9+
export class UmbPeekErrorNotificationElement extends UmbLitElement {
10+
@property({ attribute: false })
11+
public data?: UmbPeekErrorArgs;
12+
13+
public notificationHandler!: UmbNotificationHandler;
14+
15+
async #onClick() {
16+
const modalManager = await this.getContext(UMB_MODAL_MANAGER_CONTEXT);
17+
18+
modalManager.open(this, UMB_ERROR_VIEWER_MODAL, { data: this.data?.details });
19+
20+
this.notificationHandler.close();
21+
}
22+
23+
protected override render() {
24+
return this.data
25+
? html`<uui-toast-notification-layout headline=${ifDefined(this.data.headline)}
26+
>${this.data.message}${this.data.details
27+
? html`<uui-button
28+
slot="actions"
29+
look="primary"
30+
color="danger"
31+
label=${this.localize.term('defaultdialogs_seeErrorAction')}
32+
@click=${this.#onClick}></uui-button>`
33+
: nothing}</uui-toast-notification-layout
34+
>`
35+
: nothing;
36+
}
37+
}
38+
39+
declare global {
40+
interface HTMLElementTagNameMap {
41+
'umb-peek-error-notification': UmbPeekErrorNotificationElement;
42+
}
43+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { UMB_NOTIFICATION_CONTEXT } from '../../notification.context.js';
2+
import { UmbControllerBase } from '@umbraco-cms/backoffice/class-api';
3+
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
4+
import type { UmbPeekErrorArgs } from '../../types.js';
5+
6+
import './peek-error-notification.element.js';
7+
8+
export class UmbPeekErrorController extends UmbControllerBase {
9+
async open(args: UmbPeekErrorArgs): Promise<void> {
10+
const context = await this.getContext(UMB_NOTIFICATION_CONTEXT);
11+
12+
context.peek('danger', {
13+
elementName: 'umb-peek-error-notification',
14+
data: args,
15+
});
16+
17+
// This is a one time off, so we can destroy our selfs.
18+
this.destroy();
19+
20+
return;
21+
}
22+
}
23+
24+
/**
25+
*
26+
* @param host {UmbControllerHost} - The host controller
27+
* @param args {UmbPeekErrorArgs} - The data to pass to the notification
28+
* @returns {UmbPeekErrorController} The notification peek controller instance
29+
*/
30+
export function umbPeekError(host: UmbControllerHost, args: UmbPeekErrorArgs) {
31+
return new UmbPeekErrorController(host).open(args);
32+
}

src/Umbraco.Web.UI.Client/src/packages/core/notification/extractUmbNotificationColor.function.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { UmbNotificationColor } from './notification.context.js';
21
import { EventMessageTypeModel } from '@umbraco-cms/backoffice/external/backend-api';
2+
import type { UmbNotificationColor } from './types.js';
33

44
/**
55
*
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import './layouts/default/index.js';
2-
3-
export * from './notification.context.js';
2+
export * from './controllers/peek-error/index.js';
3+
export * from './extractUmbNotificationColor.function.js';
4+
export * from './isUmbNotifications.function.js';
5+
export * from './modals/error-viewer/index.js';
46
export * from './notification-handler.js';
7+
export * from './notification.context.js';
58

6-
export * from './isUmbNotifications.function.js';
7-
export * from './extractUmbNotificationColor.function.js';
9+
export type * from './types.js';

0 commit comments

Comments
 (0)