-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
web: Normalize client-side error handling #13595
Open
GirlBossRush
wants to merge
4
commits into
main
Choose a base branch
from
error-normalizing
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
4d880a8
web: Clean up error handling. Prep for permission checks.
GirlBossRush fc9a934
web: Add better error reporting to differentiate API errors from network
GirlBossRush ee0405e
web: Tidy error checking behavior.
GirlBossRush 7a97b21
Fix issue where messages do not include title. Allow for type safety in
GirlBossRush File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { EventGeo, EventUser } from "@goauthentik/admin/events/utils"; | ||
import { EventUser, formatGeoEvent } from "@goauthentik/admin/events/utils"; | ||
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config"; | ||
import { EventWithContext } from "@goauthentik/common/events"; | ||
import { actionToLabel } from "@goauthentik/common/labels"; | ||
|
@@ -10,6 +10,7 @@ import "@goauthentik/elements/buttons/ModalButton"; | |
import "@goauthentik/elements/buttons/SpinnerButton"; | ||
import { PaginatedResponse } from "@goauthentik/elements/table/Table"; | ||
import { Table, TableColumn } from "@goauthentik/elements/table/Table"; | ||
import { SlottedTemplateResult } from "@goauthentik/elements/types"; | ||
|
||
import { msg } from "@lit/localize"; | ||
import { CSSResult, TemplateResult, css, html } from "lit"; | ||
|
@@ -68,20 +69,24 @@ export class RecentEventsCard extends Table<Event> { | |
</div>`; | ||
} | ||
|
||
row(item: EventWithContext): TemplateResult[] { | ||
row(item: EventWithContext): SlottedTemplateResult[] { | ||
return [ | ||
html`<div><a href="${`#/events/log/${item.pk}`}">${actionToLabel(item.action)}</a></div> | ||
<small>${item.app}</small>`, | ||
EventUser(item), | ||
html`<div>${getRelativeTime(item.created)}</div> | ||
<small>${item.created.toLocaleString()}</small>`, | ||
html` <div>${item.clientIp || msg("-")}</div> | ||
<small>${EventGeo(item)}</small>`, | ||
<small>${formatGeoEvent(item)}</small>`, | ||
html`<span>${item.brand?.name || msg("-")}</span>`, | ||
]; | ||
} | ||
|
||
renderEmpty(): TemplateResult { | ||
renderEmpty(inner?: SlottedTemplateResult): TemplateResult { | ||
if (this.error) { | ||
return super.renderEmpty(inner); | ||
} | ||
|
||
return super.renderEmpty( | ||
Comment on lines
-84
to
+89
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixes issue where errors don't render when the empty state is active. IMO this needs fixing in the base |
||
html`<ak-empty-state header=${msg("No Events found.")}> | ||
<div slot="body">${msg("No matching events could be found.")}</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
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs more love in a future iteration but the idea is something like events would have stronger typing, and that
formatGeoEvent
would operate like a i18n function.