-
Notifications
You must be signed in to change notification settings - Fork 5
Custom Header Links
Tom Longhurst edited this page Nov 25, 2021
·
6 revisions
The navigation bar at the top of the page is customisable, with the ability to add your own custom links or text to it.
A use case I had was with my authentication, I had access to the user's name.
It's a nice little touch to have a "Hi, name!" message on your page.
You can do this by creating a class that implements IBDTestCustomHeaderLinksProvider
and registering it in the options when calling the UseBDTestReportServer
, just like the data store.
public class CustomHeaderProvider : IBDTestCustomHeaderLinksProvider
{
public IEnumerable<CustomLinkData> GetCustomLinks()
{
var name = GetName(); // Some logic you implement to get the user's name
return new List<CustomLinkData>
{
// Null if you don't want a link, otherwise provide a URL instead!
new CustomLinkData($"Hi, {name}!", null),
new CustomLinkData($"Google!", new Uri("https://www.google.com")),
};
}
}
app.UseBDTestReportServer(options =>
{
...
options.CustomHeaderLinksProvider = new CustomHeaderProvider();
...
});