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