chore: use code snippet for signal debugging
Signed-off-by: Heikki Hellgren <heikki.hellgren@op.fi>
This commit is contained in:
@@ -14,7 +14,6 @@ import { GridProps } from '@material-ui/core/Grid';
|
||||
import { IconComponent } from '@backstage/core-plugin-api';
|
||||
import { PropsWithChildren } from 'react';
|
||||
import { ReactNode } from 'react';
|
||||
import { RouteRef } from '@backstage/core-plugin-api';
|
||||
|
||||
// @public
|
||||
export function createDevApp(): DevAppBuilder;
|
||||
@@ -43,8 +42,7 @@ export type DevAppPageOptions = {
|
||||
children?: JSX.Element;
|
||||
title?: string;
|
||||
icon?: IconComponent;
|
||||
sideBarItem?: JSX.Element;
|
||||
routeRef?: RouteRef;
|
||||
sidebarItem?: JSX.Element;
|
||||
};
|
||||
|
||||
// @public (undocumented)
|
||||
|
||||
@@ -80,9 +80,7 @@ export type DevAppPageOptions = {
|
||||
children?: JSX.Element;
|
||||
title?: string;
|
||||
icon?: IconComponent;
|
||||
sideBarItem?: JSX.Element;
|
||||
|
||||
routeRef?: RouteRef;
|
||||
sidebarItem?: JSX.Element;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -144,8 +142,8 @@ export class DevAppBuilder {
|
||||
this.defaultPage = path;
|
||||
}
|
||||
|
||||
if (opts.sideBarItem) {
|
||||
this.sidebarItems.push(opts.sideBarItem);
|
||||
if (opts.sidebarItem) {
|
||||
this.sidebarItems.push(opts.sidebarItem);
|
||||
} else if (opts.title) {
|
||||
this.sidebarItems.push(
|
||||
<SidebarItem
|
||||
@@ -157,28 +155,14 @@ export class DevAppBuilder {
|
||||
);
|
||||
}
|
||||
|
||||
if (opts.routeRef) {
|
||||
const Elem = () => <>{opts.element}</>;
|
||||
attachComponentData(Elem, 'core.mountPoint', opts.routeRef);
|
||||
|
||||
this.routes.push(
|
||||
<MaybeGatheringRoute
|
||||
key={path}
|
||||
path={path}
|
||||
element={<Elem />}
|
||||
children={opts.children}
|
||||
/>,
|
||||
);
|
||||
} else {
|
||||
this.routes.push(
|
||||
<MaybeGatheringRoute
|
||||
key={path}
|
||||
path={path}
|
||||
element={opts.element}
|
||||
children={opts.children}
|
||||
/>,
|
||||
);
|
||||
}
|
||||
this.routes.push(
|
||||
<MaybeGatheringRoute
|
||||
key={path}
|
||||
path={path}
|
||||
element={opts.element}
|
||||
children={opts.children}
|
||||
/>,
|
||||
);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,8 +35,7 @@ const notificationsDebug = createBackendPlugin({
|
||||
interval = setInterval(async () => {
|
||||
await notifications.send({
|
||||
recipients: {
|
||||
type: 'entity',
|
||||
entityRef: 'user:development/guest',
|
||||
type: 'broadcast',
|
||||
},
|
||||
payload: { title: 'Test notification' },
|
||||
});
|
||||
|
||||
@@ -470,7 +470,7 @@ export async function createRouter(
|
||||
|
||||
if (!recipients || !title) {
|
||||
logger.error(`Invalid notification request received`);
|
||||
throw new InputError();
|
||||
throw new InputError(`Invalid notification request received`);
|
||||
}
|
||||
|
||||
const origin = credentials.principal.subject;
|
||||
@@ -496,8 +496,10 @@ export async function createRouter(
|
||||
try {
|
||||
users = await getUsersForEntityRef(entityRef);
|
||||
} catch (e) {
|
||||
throw new InputError();
|
||||
logger.error(`Failed to resolve notification receivers: ${e}`);
|
||||
throw new InputError('Failed to resolve notification receivers', e);
|
||||
}
|
||||
|
||||
const userNotifications = await sendUserNotifications(
|
||||
baseNotification,
|
||||
users,
|
||||
|
||||
@@ -15,10 +15,8 @@
|
||||
*/
|
||||
import React from 'react';
|
||||
import { createDevApp } from '@backstage/dev-utils';
|
||||
import { notificationsPlugin } from '../src/plugin';
|
||||
import { NotificationsPage } from '../src/components/NotificationsPage';
|
||||
import { NotificationsPage, notificationsPlugin } from '../src/plugin';
|
||||
import { NotificationsSidebarItem } from '../src';
|
||||
import { rootRouteRef } from '../src/routes';
|
||||
|
||||
// TODO: How to sign in here as guest user?
|
||||
createDevApp()
|
||||
@@ -26,7 +24,6 @@ createDevApp()
|
||||
.addPage({
|
||||
element: <NotificationsPage />,
|
||||
path: '/notifications',
|
||||
sideBarItem: <NotificationsSidebarItem />,
|
||||
routeRef: rootRouteRef,
|
||||
sidebarItem: <NotificationsSidebarItem />,
|
||||
})
|
||||
.render();
|
||||
|
||||
Reference in New Issue
Block a user