Skip to content

Commit

Permalink
feat: allow passing redirect href to Button
Browse files Browse the repository at this point in the history
  • Loading branch information
DavideIadeluca committed Oct 3, 2024
1 parent d0f7299 commit 645d207
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions js/src/common/components/LoginAsUserButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import ImpersonateModal from './ImpersonateModal';

export interface ILoginAsUserButtonAttrs extends IButtonAttrs {
user: User;
redirectTo?: string;
}

export default class LoginAsUserButton extends Button<ILoginAsUserButtonAttrs> {
Expand All @@ -18,10 +19,11 @@ export default class LoginAsUserButton extends Button<ILoginAsUserButtonAttrs> {
}

loginAsUser(): void {
const { user } = this.attrs;
console.log('loginAsUser', user);
const { user, redirectTo } = this.attrs;
app.modal.show(ImpersonateModal, {
callback: () => window.location.reload(),
callback: () => {
redirectTo ? (window.location.href = redirectTo) : window.location.reload();
},
user,
});
}
Expand Down

0 comments on commit 645d207

Please sign in to comment.