Skip to content

Custom Sidebar Links

Tom Longhurst edited this page Nov 25, 2021 · 7 revisions

Similar to the header links, you are able to add links to the left sidebar as well.

The process is pretty much the same, however the interface you need to implement this time is instead IBDTestCustomSidebarLinksProvider And again, register this in the options when calling the UseBDTestReportServer

public class CustomSidebarLinkProvider: IBDTestCustomSidebarLinksProvider
    {
        public IEnumerable<CustomLinkData> GetCustomLinks([AllowNull] BDTestOutputModel currentTestReport)
        {
            // If you're inside a test report, the `BDTestOutputModel` parameter will not be null, and can give you information about the current test
            // so you can use some logic to create dynamic, test-relevant links.
            // If the user is not in a test report, this will be null, so check it first!

            return new List<CustomLinkData>
            {
                new CustomLinkData("Some Link", new Uri("https://www.tomlonghurst.com"))
            };
        }
    }

And in startup, make sure to add:

app.UseBDTestReportServer(options =>
{
    ...
    options.CustomSidebarLinkProvider = new CustomSidebarLinkProvider();
    ...
});
Clone this wiki locally