-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add better user creation flow (#136)
Closes: #134
- Loading branch information
Showing
6 changed files
with
114 additions
and
5 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
src/client/src/app/components/users/user-created-dialog/user-created-dialog.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<p-dialog | ||
[header]="translations.users_userCreatedDialog_title() | interpolate: user()" | ||
[visible]="visible()" | ||
(visibleChange)="visible.set($event)" | ||
[modal]="true" | ||
[draggable]="false" | ||
[resizable]="false" | ||
> | ||
<div class="flex flex-col items-end gap-2"> | ||
<div class="grid grid-cols-1 gap-2 sm:grid-cols-2"> | ||
<p-button | ||
styleClass="w-full" | ||
[icon]="'i-[mdi--text-account]'" | ||
[label]="translations.users_userCreatedDialog_copyWelcomeMessage()" | ||
(onClick)="copyWelcomeMessage()" | ||
/> | ||
@if (user()?.loginToken; as loginToken) { | ||
<p-button | ||
styleClass="w-full" | ||
[icon]="'i-[mdi--lock]'" | ||
[label]="translations.users_userCreatedDialog_copyPassword()" | ||
(onClick)="copyPassword(loginToken)" | ||
/> | ||
} | ||
</div> | ||
<p-button | ||
styleClass="w-full" | ||
[icon]="'i-[mdi--check]'" | ||
[label]="translations.shared_done()" | ||
(onClick)="visible.set(false)" | ||
[text]="true" | ||
/> | ||
</div> | ||
</p-dialog> |
51 changes: 51 additions & 0 deletions
51
src/client/src/app/components/users/user-created-dialog/user-created-dialog.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { CommonModule } from '@angular/common'; | ||
import { ChangeDetectionStrategy, Component, inject, signal } from '@angular/core'; | ||
import copyToClipboard from 'copy-to-clipboard'; | ||
import { MessageService } from 'primeng/api'; | ||
import { ButtonModule } from 'primeng/button'; | ||
import { DialogModule } from 'primeng/dialog'; | ||
|
||
import { interpolate, InterpolatePipe } from '../../../directives/interpolate.pipe'; | ||
import { User } from '../../../models/parsed-models'; | ||
import { TranslateService } from '../../../services/translate.service'; | ||
|
||
@Component({ | ||
selector: 'app-user-created-dialog', | ||
standalone: true, | ||
imports: [ButtonModule, CommonModule, DialogModule, InterpolatePipe], | ||
templateUrl: './user-created-dialog.component.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class UserCreatedDialogComponent { | ||
private readonly _messageService = inject(MessageService); | ||
protected readonly translations = inject(TranslateService).translations; | ||
|
||
protected readonly visible = signal(false); | ||
protected readonly user = signal<User | undefined>(undefined); | ||
|
||
public open(user: User) { | ||
this.user.set(user); | ||
this.visible.set(true); | ||
} | ||
|
||
protected copyWelcomeMessage() { | ||
const message = interpolate(this.translations.users_userCreatedDialog_welcomeMessage(), { | ||
url: (document.head.querySelector('base') as HTMLBaseElement).href, | ||
}); | ||
copyToClipboard(message); | ||
this._messageService.add({ | ||
severity: 'success', | ||
summary: this.translations.users_userCreatedDialog_welcomeMessageCopied(), | ||
life: 2000, | ||
}); | ||
} | ||
|
||
protected copyPassword(password: string) { | ||
copyToClipboard(password); | ||
this._messageService.add({ | ||
severity: 'success', | ||
summary: this.translations.users_dialog_loginTokenCopied(), | ||
life: 2000, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters