Skip to content

Commit

Permalink
Merge pull request DSpace#2362 from Leano1998/making_user-menu-compon…
Browse files Browse the repository at this point in the history
…ent_themeable

Making user menu component themeable
  • Loading branch information
tdonohue authored Oct 25, 2023
2 parents daef3f5 + 7606f47 commit 3058a4b
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/app/navbar/navbar.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div id="collapsingNav">
<ul class="navbar-nav navbar-navigation mr-auto shadow-none">
<li *ngIf="(isXsOrSm$ | async) && (isAuthenticated$ | async)">
<ds-user-menu [inExpandableNavbar]="true"></ds-user-menu>
<ds-themed-user-menu [inExpandableNavbar]="true"></ds-themed-user-menu>
</li>
<li *ngFor="let section of (sections | async)">
<ng-container *ngComponentOutlet="(sectionMap$ | async).get(section.id)?.component; injector: (sectionMap$ | async).get(section.id)?.injector;"></ng-container>
Expand Down
2 changes: 1 addition & 1 deletion src/app/shared/auth-nav-menu/auth-nav-menu.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<a href="javascript:void(0);" role="button" [attr.aria-label]="'nav.user-profile-menu-and-logout' |translate" (click)="$event.preventDefault()" [title]="'nav.user-profile-menu-and-logout' | translate" class="dropdownLogout px-1" [attr.data-test]="'user-menu' | dsBrowserOnly" ngbDropdownToggle>
<i class="fas fa-user-circle fa-lg fa-fw"></i></a>
<div class="logoutDropdownMenu" ngbDropdownMenu [attr.aria-label]="'nav.user-profile-menu-and-logout' |translate">
<ds-user-menu></ds-user-menu>
<ds-themed-user-menu></ds-themed-user-menu>
</div>
</div>
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ describe('AuthNavMenuComponent', () => {
component = null;
});
it('should render UserMenuComponent component', () => {
const logoutDropdownMenu = deNavMenuItem.query(By.css('ds-user-menu'));
const logoutDropdownMenu = deNavMenuItem.query(By.css('ds-themed-user-menu'));
expect(logoutDropdownMenu.nativeElement).toBeDefined();
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import {Component, Input} from '@angular/core';
import {ThemedComponent} from '../../theme-support/themed.component';
import {UserMenuComponent} from './user-menu.component';

/**
* This component represents the user nav menu.
*/
@Component({
selector: 'ds-themed-user-menu',
templateUrl: './../../theme-support/themed.component.html',
styleUrls: []
})
export class ThemedUserMenuComponent extends ThemedComponent<UserMenuComponent>{

/**
* The input flag to show user details in navbar expandable menu
*/
@Input() inExpandableNavbar: boolean;

protected inAndOutputNames: (keyof UserMenuComponent & keyof this)[] = ['inExpandableNavbar'];

protected getComponentName(): string {
return 'UserMenuComponent';
}

protected importThemedComponent(themeName: string): Promise<any> {
return import((`../../../../themes/${themeName}/app/shared/auth-nav-menu/user-menu/user-menu.component`));
}

protected importUnthemedComponent(): Promise<any> {
return import('./user-menu.component');
}
}
2 changes: 2 additions & 0 deletions src/app/shared/shared.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ import {
} from '../item-page/simple/field-components/specific-field/title/themed-item-page-field.component';
import { BitstreamListItemComponent } from './object-list/bitstream-list-item/bitstream-list-item.component';
import { NgxPaginationModule } from 'ngx-pagination';
import { ThemedUserMenuComponent } from './auth-nav-menu/user-menu/themed-user-menu.component';
import { ThemedLangSwitchComponent } from './lang-switch/themed-lang-switch.component';

const MODULES = [
Expand Down Expand Up @@ -330,6 +331,7 @@ const COMPONENTS = [
AuthNavMenuComponent,
ThemedAuthNavMenuComponent,
UserMenuComponent,
ThemedUserMenuComponent,
DsSelectComponent,
ErrorComponent,
LangSwitchComponent,
Expand Down
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Component } from '@angular/core';
import { UserMenuComponent as BaseComponent } from '../../../../../../app/shared/auth-nav-menu/user-menu/user-menu.component';

/**
* Component representing the {@link UserMenuComponent} of a page
*/
@Component({
selector: 'ds-user-menu',
// templateUrl: 'user-menu.component.html',
templateUrl: '../../../../../../app/shared/auth-nav-menu/user-menu/user-menu.component.html',
// styleUrls: ['user-menu.component.scss'],
styleUrls: ['../../../../../../app/shared/auth-nav-menu/user-menu/user-menu.component.scss'],
})
export class UserMenuComponent extends BaseComponent {
}
2 changes: 2 additions & 0 deletions src/themes/custom/lazy-theme.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ import { ItemStatusComponent } from './app/item-page/edit-item-page/item-status/
import { EditBitstreamPageComponent } from './app/bitstream-page/edit-bitstream-page/edit-bitstream-page.component';
import { FormModule } from '../../app/shared/form/form.module';
import { RequestCopyModule } from 'src/app/request-copy/request-copy.module';
import {UserMenuComponent} from './app/shared/auth-nav-menu/user-menu/user-menu.component';

const DECLARATIONS = [
FileSectionComponent,
Expand Down Expand Up @@ -239,6 +240,7 @@ const DECLARATIONS = [
SubmissionSectionUploadFileComponent,
ItemStatusComponent,
EditBitstreamPageComponent,
UserMenuComponent,
];

@NgModule({
Expand Down

0 comments on commit 3058a4b

Please sign in to comment.