Skip to content

Commit 986326c

Browse files
committed
refactor(admin/profile): move Create Account action from profile page to admin dashboard header
1 parent e2ba884 commit 986326c

5 files changed

Lines changed: 27 additions & 14 deletions

File tree

src/app/features/admin/components/admin-dashboard/admin-dashboard.component.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@ <h2>Admin Dashboard</h2>
1212
<span class="meta-pill" *ngIf="previewDetail">{{ previewDetail }}</span>
1313
</div>
1414
</div>
15+
16+
<div class="admin-header__actions">
17+
<button
18+
*ngIf="canCreateAccount"
19+
pButton
20+
type="button"
21+
label="Create Account"
22+
icon="pi pi-user-plus"
23+
class="p-button-outlined"
24+
(click)="createAccount()">
25+
</button>
26+
</div>
1527
</div>
1628
</p-card>
1729

src/app/features/admin/components/admin-dashboard/admin-dashboard.component.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@
2828
gap: 0.45rem;
2929
}
3030

31+
.admin-header__actions {
32+
display: inline-flex;
33+
align-items: center;
34+
gap: 0.5rem;
35+
flex-wrap: wrap;
36+
}
37+
3138
.meta-pill {
3239
display: inline-flex;
3340
align-items: center;

src/app/features/admin/components/admin-dashboard/admin-dashboard.component.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ export class AdminDashboardComponent implements OnInit {
9999
return this.users.filter((user) => user.roles.includes(AppRole.User)).length;
100100
}
101101

102+
get canCreateAccount(): boolean {
103+
return this.authService.hasRole(AppRole.Administrator);
104+
}
105+
102106
ngOnInit(): void {
103107
this.rows = this.preferencesService.preferences().defaultTablePageSize;
104108
this.loadUsers();
@@ -195,6 +199,10 @@ export class AdminDashboardComponent implements OnInit {
195199
});
196200
}
197201

202+
createAccount(): void {
203+
void this.authService.openRegisterPage();
204+
}
205+
198206
trackByUserId(index: number, user: UserSummaryDto): string {
199207
return user.id;
200208
}

src/app/features/profile/components/user-profile-security/user-profile-security.component.html

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,6 @@ <h2>User Profile & Security</h2>
2121
</div>
2222

2323
<div class="profile-header__actions">
24-
<button
25-
*ngIf="canCreateAccount()"
26-
pButton
27-
type="button"
28-
label="Create Account"
29-
icon="pi pi-user-plus"
30-
class="p-button-outlined"
31-
(click)="register()">
32-
</button>
3324
<button pButton type="button" label="Logout" icon="pi pi-sign-out" class="p-button-outlined" (click)="logout()"></button>
3425
</div>
3526
</div>

src/app/features/profile/components/user-profile-security/user-profile-security.component.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ export class UserProfileSecurityComponent {
2424
readonly claims = computed(() => this.authService.userClaims());
2525
readonly roles = computed(() => this.authService.userRoles());
2626
readonly currentUserId = computed(() => this.authService.currentUserId());
27-
readonly canCreateAccount = computed(() => this.authService.hasRole(AppRole.Administrator));
2827

2928
readonly userDisplayName = computed(() => {
3029
const claims = this.claims();
@@ -121,10 +120,6 @@ export class UserProfileSecurityComponent {
121120
this.authService.logout();
122121
}
123122

124-
register(): void {
125-
void this.authService.openRegisterPage();
126-
}
127-
128123
private serializeClaimValue(value: unknown): string {
129124
if (Array.isArray(value)) {
130125
return value.map((item) => String(item)).join(', ');

0 commit comments

Comments
 (0)