Skip to content

Commit

Permalink
fix(admin-ui): Add descriptive error when using getBreadcrumbs wrong
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbromley committed Oct 27, 2023
1 parent 1095c74 commit b8c4a77
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,19 @@ export function registerRouteComponent<
const breadcrumbSubject$ = new BehaviorSubject<BreadcrumbValue>(options.breadcrumb ?? '');
const titleSubject$ = new BehaviorSubject<string | undefined>(options.title);

if (getBreadcrumbs != null && (query == null || entityKey == null)) {
console.error(
[
`[${
options.path ?? 'custom'
} route] When using the "getBreadcrumbs" option, the "query" and "entityKey" options must also be provided.`,
``,
`Alternatively, use the "breadcrumb" option instead, or use the "PageMetadataService" inside your Angular component`,
`or the "usePageMetadata" React hook to set the breadcrumb.`,
].join('\n'),
);
}

const resolveFn:
| ResolveFn<{
entity: Observable<ResultOf<T>[Field] | null>;
Expand Down Expand Up @@ -118,7 +131,7 @@ export function registerRouteComponent<
data: {
breadcrumb: breadcrumbSubject$,
...(options.routeConfig?.data ?? {}),
...(getBreadcrumbs
...(getBreadcrumbs && query && entityKey
? {
breadcrumb: data =>
data.detail.entity.pipe(map((entity: any) => getBreadcrumbs(entity))),
Expand Down

0 comments on commit b8c4a77

Please sign in to comment.