-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- updated dbx-error presentation - added ability to register error widgets
- Loading branch information
Showing
36 changed files
with
514 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
apps/demo/src/app/modules/doc/modules/interaction/component/error.widget.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
export const CUSTOM_TEST_ERROR_CODE = 'CUSTOM_ERROR_WITH_WIDGET'; | ||
|
||
@Component({ | ||
template: ` | ||
<p>Custom widget content</p> | ||
` | ||
}) | ||
export class DocInteractionCustomErrorWidgetComponent {} |
16 changes: 16 additions & 0 deletions
16
apps/demo/src/app/modules/doc/modules/interaction/container/error.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<dbx-content-container> | ||
<doc-feature-layout header="Error" hint="The error module is used for displaying errors within the app."> | ||
<!-- Examples --> | ||
<doc-feature-example header="dbx-error" hint="Component that displays an error message. Expected input is a ReadableError"> | ||
<dbx-error [error]="readableErrorWithoutCode"></dbx-error> | ||
<dbx-error [error]="readableError"></dbx-error> | ||
<dbx-error [error]="longerReadableError"></dbx-error> | ||
<dbx-error [error]="customTestError"></dbx-error> | ||
</doc-feature-example> | ||
<doc-feature-example header="dbx-error-details" hint="Component that is used by the error popover. Displays all information about an error."> | ||
<dbx-error-details [error]="longerReadableError"></dbx-error-details> | ||
<h4>Custom Widget</h4> | ||
<dbx-error-details [error]="customTestError"></dbx-error-details> | ||
</doc-feature-example> | ||
</doc-feature-layout> | ||
</dbx-content-container> |
33 changes: 33 additions & 0 deletions
33
apps/demo/src/app/modules/doc/modules/interaction/container/error.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Component } from '@angular/core'; | ||
import { readableError, ReadableError, serverError } from '@dereekb/util'; | ||
import { LOREM } from '../../shared/lorem'; | ||
import { CUSTOM_TEST_ERROR_CODE } from '../component/error.widget.component'; | ||
|
||
const TEST_ERROR_CODE = 'A_VERY_LONG_TEST_ERROR_CODE_USED_FOR_REFERENCE'; | ||
|
||
@Component({ | ||
templateUrl: './error.component.html' | ||
}) | ||
export class DocInteractionErrorComponent { | ||
readonly readableErrorWithoutCode: ReadableError = { message: 'This is an error without an error code.' }; | ||
|
||
readonly readableError: ReadableError = readableError(TEST_ERROR_CODE, 'This is the example error message.'); | ||
|
||
readonly longerReadableError: ReadableError = serverError({ | ||
code: TEST_ERROR_CODE, | ||
message: LOREM, | ||
status: 200, | ||
data: { | ||
serverErrorDataInfo: { | ||
reason: 'test_reason', | ||
additional_info: 'The server tried its best.' | ||
} | ||
} | ||
}); | ||
|
||
readonly customTestError: ReadableError = serverError({ | ||
code: CUSTOM_TEST_ERROR_CODE, | ||
message: 'This error has a custom widget associated with it.', | ||
status: 200 | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
packages/dbx-web/src/lib/error/default.error.widget.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Component } from '@angular/core'; | ||
import { ServerError, ServerErrorResponseData } from '@dereekb/util'; | ||
import { AbstractDbxErrorWidgetComponent } from './error.widget.directive'; | ||
|
||
@Component({ | ||
template: ` | ||
<dbx-label-block header="Error Code">{{ code }}</dbx-label-block> | ||
<dbx-label-block header="Error Data" *ngIf="data"> | ||
<p class="dbx-json">{{ serverErrorData | json }}</p> | ||
</dbx-label-block> | ||
`, | ||
host: { | ||
class: 'd-block dbx-error-default-error-widget dbx-content-container' | ||
} | ||
}) | ||
export class DbxErrorDefaultErrorWidgetComponent extends AbstractDbxErrorWidgetComponent { | ||
get serverErrorData(): ServerErrorResponseData | undefined { | ||
return (this.data as ServerError).data; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
<div *ngIf="error" class="dbx-error dbx-warn"> | ||
<h4>An error occured.</h4> | ||
<!-- <p class="dbx-error-code" *ngIf="errorData.code">{{ errorData.code }}</p> --> | ||
<p class="dbx-error-message" *ngIf="message">{{ message }}</p> | ||
<button [disabled]="isDefaultError" #buttonPopoverOrigin mat-icon-button class="dbx-error-button" (click)="openErrorPopover()"><mat-icon>error</mat-icon></button> | ||
<span class="dbx-error-message" *ngIf="message">{{ message }}</span> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Component, Input } from '@angular/core'; | ||
import { Maybe, ReadableError } from '@dereekb/util'; | ||
|
||
@Component({ | ||
selector: 'dbx-error-details', | ||
template: ` | ||
<dbx-error-widget-view [error]="error"></dbx-error-widget-view> | ||
`, | ||
host: { | ||
class: 'dbx-block dbx-error-details' | ||
} | ||
}) | ||
export class DbxErrorDetailsComponent { | ||
@Input() | ||
error?: Maybe<ReadableError>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,32 @@ | ||
import { MatIconModule } from '@angular/material/icon'; | ||
import { NgModule } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { DbxReadableErrorComponent } from './error.component'; | ||
import { DbxLoadingErrorDirective } from './error.loading.directive'; | ||
import { DbxActionErrorDirective } from './error.action.directive'; | ||
import { MatButtonModule } from '@angular/material/button'; | ||
import { DbxErrorPopoverComponent } from './error.popover.component'; | ||
import { DbxErrorDetailsComponent } from './error.details.component'; | ||
import { DbxPopoverInteractionContentModule } from '../interaction/popover/popover.content.module'; | ||
import { DbxErrorWidgetViewComponent } from './error.widget.component'; | ||
import { DbxInjectionComponentModule } from '@dereekb/dbx-core'; | ||
import { DbxErrorDefaultErrorWidgetComponent } from './default.error.widget.component'; | ||
import { DbxTextModule } from '../layout/text/text.module'; | ||
|
||
const declarations = [ | ||
// | ||
DbxReadableErrorComponent, | ||
DbxLoadingErrorDirective, | ||
DbxActionErrorDirective, | ||
DbxErrorPopoverComponent, | ||
DbxErrorDetailsComponent, | ||
DbxErrorWidgetViewComponent, | ||
DbxErrorDefaultErrorWidgetComponent | ||
]; | ||
|
||
@NgModule({ | ||
imports: [CommonModule], | ||
declarations: [DbxReadableErrorComponent, DbxLoadingErrorDirective, DbxActionErrorDirective], | ||
exports: [DbxReadableErrorComponent, DbxLoadingErrorDirective, DbxActionErrorDirective] | ||
imports: [CommonModule, DbxTextModule, DbxInjectionComponentModule, DbxPopoverInteractionContentModule, MatButtonModule, MatIconModule], | ||
declarations, | ||
exports: declarations | ||
}) | ||
export class DbxReadableErrorModule {} |
Oops, something went wrong.