Open Closed

ABP Toolbar Action Hooks #8042


User avatar
0
BenS-FreshRF created
  • ABP Framework version: v8.3.0
  • UI Type: Blazor WASM
  • Database System: EF Core (PostgreSQL)
  • Tiered (for MVC) or Auth Server Separated (for Angular): no
  • Exception message and full stack trace:
  • Steps to reproduce the issue: Click any toolbar option

The ABP Toolbar is useful but we have a number of actions we want to perform on Logout or navigation to the My Account pages that exist on the host.

I can't find any way to hook into those actions to perform actions before redirection. For Logout I've hooked into the OpenIddict event handlers to cleanup stuff but for the My Account link I can't find any events to hook into so have had to resort to some obvious error messages to alleviate issues users may face when returning to the main application.

Regardless hooking into the OpenIddict events on the Host side requires exposing more services to perform the needed actions, services already available on the client side.

Is there any way to hook into those actions on the client before redirection to the host?


5 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    The toolbar will render as HTML link. So, there is no action hook design.

    But you can add some JavaScript to listen to the event if a toolbar link is clicked.

  • User Avatar
    0
    BenS-FreshRF created

    Ok, I've managed to attach an event handler to the Manage Account button via its Id "MenuItem_Account_Manage", still wary that the redirect will trigger before the new handler has completed but is working for now.

    The Logout button however doesn't have an Id or any classes or any other parameters to make it easy to attach event handlers to. Can the next version add an Id to that button please?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    The Logout button however doesn't have an Id or any classes or any other parameters to make it easy to attach event handlers to.

    Can you share the HTML code of the whole menu?

    I think you can use the CSS selector to query the Logout button.

    Thanks.

  • User Avatar
    0
    BenS-FreshRF created

    The My Account button has an Id, but Logout does not. It could be selected by using "a.dropdown-item:last-child" or the like, but that's a very fragile way of implementing event handlers.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    ok, I will add an id to the logout element.

Made with ❤️ on ABP v9.1.0-preview. Updated on December 13, 2024, 06:09