feat(ui): move settings button to sidebar footer row (#1469)
This commit is contained in:
@@ -107,6 +107,19 @@
|
||||
</span>
|
||||
</button>
|
||||
|
||||
<a
|
||||
class="sidebar-icon-button sidebar-mobile-landscape-action"
|
||||
[class.active-route]="isSettingsActive()"
|
||||
[attr.aria-current]="isSettingsActive() ? 'page' : null"
|
||||
[routerLink]="['/settings']"
|
||||
[attr.aria-label]="t('settings')"
|
||||
[pTooltip]="t('settings')"
|
||||
[tooltipDisabled]="!layoutService.isDesktop()"
|
||||
tooltipPosition="bottom"
|
||||
>
|
||||
<i class="pi pi-cog" aria-hidden="true"></i>
|
||||
</a>
|
||||
|
||||
@if (currentUser(); as user) {
|
||||
<button
|
||||
type="button"
|
||||
@@ -209,6 +222,20 @@
|
||||
<span class="sidebar-footer-action-label">{{ t('notifications') }}</span>
|
||||
</button>
|
||||
|
||||
<a
|
||||
class="sidebar-action-link sidebar-footer-action"
|
||||
[class.active-route]="isSettingsActive()"
|
||||
[attr.aria-current]="isSettingsActive() ? 'page' : null"
|
||||
[routerLink]="['/settings']"
|
||||
[attr.aria-label]="t('settings')"
|
||||
[pTooltip]="t('settings')"
|
||||
[tooltipDisabled]="!layoutService.isDesktop()"
|
||||
tooltipPosition="top"
|
||||
>
|
||||
<i class="pi pi-cog" aria-hidden="true"></i>
|
||||
<span class="sidebar-footer-action-label">{{ t('settings') }}</span>
|
||||
</a>
|
||||
|
||||
</div>
|
||||
@if (currentUser(); as user) {
|
||||
<div class="sidebar-footer-bottom">
|
||||
@@ -344,17 +371,8 @@
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="user-account-popover-header-actions">
|
||||
<button
|
||||
appButton
|
||||
type="button"
|
||||
(click)="openSettings()"
|
||||
>
|
||||
<i class="pi pi-cog" aria-hidden="true"></i>
|
||||
<span>{{ t('settings') }}</span>
|
||||
</button>
|
||||
|
||||
@if (updateAvailable()) {
|
||||
@if (updateAvailable()) {
|
||||
<div class="user-account-popover-header-actions">
|
||||
<button
|
||||
appButton
|
||||
variant="primary"
|
||||
@@ -364,8 +382,8 @@
|
||||
<i class="pi pi-arrow-up-right" aria-hidden="true"></i>
|
||||
<span>{{ t('updateAvailable') }}</span>
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</header>
|
||||
|
||||
<div class="user-account-popover-body">
|
||||
|
||||
@@ -129,6 +129,7 @@
|
||||
border-radius: var(--sidebar-row-radius);
|
||||
color: var(--text-color-secondary);
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
transition: background-color var(--transition-fast), color var(--transition-fast);
|
||||
|
||||
&:hover {
|
||||
@@ -199,7 +200,7 @@
|
||||
.sidebar-footer {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-1);
|
||||
gap: var(--space-2);
|
||||
padding-top: var(--space-2);
|
||||
margin-top: var(--space-2);
|
||||
border-top: 1px solid var(--border-color);
|
||||
@@ -222,6 +223,7 @@
|
||||
font: inherit;
|
||||
font-size: var(--text-base);
|
||||
text-align: left;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
transition: background-color var(--transition-fast), padding var(--transition-base);
|
||||
|
||||
@@ -238,6 +240,10 @@
|
||||
&.active-route {
|
||||
color: var(--primary-color);
|
||||
background-color: color-mix(in srgb, var(--primary-color) 8%, transparent);
|
||||
|
||||
.sidebar-footer-action-label {
|
||||
color: inherit;
|
||||
}
|
||||
}
|
||||
|
||||
i {
|
||||
@@ -269,6 +275,8 @@
|
||||
flex: 1 1 0;
|
||||
width: auto;
|
||||
min-width: 0;
|
||||
height: calc(var(--sidebar-row-min-height) + 0.25rem);
|
||||
min-height: calc(var(--sidebar-row-min-height) + 0.25rem);
|
||||
justify-content: center;
|
||||
padding-left: 0;
|
||||
padding-right: 0;
|
||||
@@ -599,6 +607,11 @@
|
||||
&:hover {
|
||||
background-color: var(--surface-hover);
|
||||
}
|
||||
|
||||
&.active-route {
|
||||
background-color: color-mix(in srgb, var(--primary-color) 8%, transparent);
|
||||
color: var(--primary-color);
|
||||
}
|
||||
}
|
||||
|
||||
.sidebar-footer {
|
||||
|
||||
@@ -46,9 +46,11 @@ describe('AppSidebarComponent', () => {
|
||||
let hasActiveImport: WritableSignal<boolean>;
|
||||
const sidebarCollapsed = signal(false);
|
||||
const isDesktop = signal(true);
|
||||
const currentPath = signal('/dashboard');
|
||||
const layoutService = {
|
||||
sidebarCollapsed,
|
||||
isDesktop,
|
||||
currentPath,
|
||||
desktopSidebarCollapsed: computed(() => isDesktop() && sidebarCollapsed()),
|
||||
librarySort: signal({ field: 'name', order: 'desc' }),
|
||||
shelfSort: signal({ field: 'name', order: 'asc' }),
|
||||
@@ -116,6 +118,7 @@ describe('AppSidebarComponent', () => {
|
||||
fixture = TestBed.createComponent(AppSidebarComponent);
|
||||
component = fixture.componentInstance;
|
||||
layoutService.isDesktop.set(true);
|
||||
layoutService.currentPath.set('/dashboard');
|
||||
layoutService.closeMobileSidebar.mockReset();
|
||||
});
|
||||
|
||||
@@ -183,6 +186,16 @@ describe('AppSidebarComponent', () => {
|
||||
expect(component.userInitials()).toBe('A');
|
||||
});
|
||||
|
||||
it('marks settings active from the current layout path', () => {
|
||||
const sidebar = component as unknown as { isSettingsActive: () => boolean };
|
||||
|
||||
expect(sidebar.isSettingsActive()).toBe(false);
|
||||
|
||||
layoutService.currentPath.set('/settings');
|
||||
|
||||
expect(sidebar.isSettingsActive()).toBe(true);
|
||||
});
|
||||
|
||||
it('returns an empty string when no user is signed in', () => {
|
||||
currentUser.set(null);
|
||||
|
||||
|
||||
@@ -163,6 +163,7 @@ export class AppSidebarComponent {
|
||||
const user = this.currentUser();
|
||||
return !!user && (user.permissions.admin || user.permissions.canUpload);
|
||||
});
|
||||
protected readonly isSettingsActive = computed(() => this.layoutService.currentPath() === '/settings');
|
||||
|
||||
readonly searchShortcutLabel = detectSearchShortcut(
|
||||
typeof navigator !== 'undefined' ? navigator.userAgent : ''
|
||||
@@ -278,11 +279,6 @@ export class AppSidebarComponent {
|
||||
this.closeUserPopover();
|
||||
}
|
||||
|
||||
protected openSettings(): void {
|
||||
this.router.navigate(['/settings']);
|
||||
this.closeUserPopover();
|
||||
}
|
||||
|
||||
protected openChangelogDialog(): void {
|
||||
void this.dialogLauncherService.openVersionChangelogDialog().catch(() => undefined);
|
||||
this.closeUserPopover();
|
||||
|
||||
Reference in New Issue
Block a user