mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-10-01 14:41:14 +00:00
Sonarcloud issues fixes (#3499)
* Sonarcloud issues fixes * Code smell fixes * Refactoring to remove new code duplications * Sonarcloud code smell fixes part I * Sonarcloud code smell fixes part II * Missing code smell fix * Add new ESLint rules to cover fixed SonarCloud issues * Add missing command * Add missing is existing check
This commit is contained in:
@@ -75,7 +75,6 @@ describe('ActionDirective', () => {
|
||||
it('should add active route class name', () => {
|
||||
fixture.detectChanges();
|
||||
router.navigateByUrl('/dummy');
|
||||
// fixture.detectChanges();
|
||||
expect(document.body.querySelector('#test-element').className.includes('active-link-class')).toBe(true);
|
||||
});
|
||||
|
||||
|
@@ -67,7 +67,7 @@ export class ActiveLinkDirective implements OnInit, AfterContentInit {
|
||||
}
|
||||
|
||||
private render(routerUrl: string, actionUrl: string) {
|
||||
if (routerUrl && routerUrl.substring(1).startsWith(actionUrl)) {
|
||||
if (routerUrl?.substring(1).startsWith(actionUrl)) {
|
||||
this.isLinkActive = true;
|
||||
this.renderer.addClass(this.element.nativeElement, this.acaActiveLink);
|
||||
} else {
|
||||
@@ -82,6 +82,6 @@ export class ActiveLinkDirective implements OnInit, AfterContentInit {
|
||||
}
|
||||
|
||||
private resolveUrl(item): string {
|
||||
return (item.action && item.action.click && item.action.click.payload) || item.action.route;
|
||||
return item.action?.click?.payload || item.action?.route;
|
||||
}
|
||||
}
|
||||
|
@@ -58,7 +58,7 @@ export class ExpansionPanelDirective implements OnInit, OnDestroy {
|
||||
constructor(private store: Store<any>, private router: Router, private expansionPanel: MatExpansionPanel) {}
|
||||
|
||||
hasActiveLinks() {
|
||||
if (this.acaExpansionPanel && this.acaExpansionPanel.children) {
|
||||
if (this.acaExpansionPanel?.children) {
|
||||
return this.acaExpansionPanel.children.some((child) => this.router.url.startsWith(child.url || child.action.payload));
|
||||
}
|
||||
return false;
|
||||
|
@@ -57,7 +57,7 @@ export class MenuPanelDirective implements OnInit, OnDestroy {
|
||||
constructor(private store: Store<any>, private router: Router) {}
|
||||
|
||||
hasActiveLinks() {
|
||||
if (this.acaMenuPanel && this.acaMenuPanel.children) {
|
||||
if (this.acaMenuPanel?.children) {
|
||||
return this.acaMenuPanel.children.some((child) => this.router.url.startsWith(child.url || child.action.payload));
|
||||
}
|
||||
return false;
|
||||
|
@@ -57,7 +57,7 @@ export class UserMenuComponent implements OnInit {
|
||||
|
||||
ngOnInit() {
|
||||
this.getUserInfo();
|
||||
if (this.data && this.data.items) {
|
||||
if (this.data?.items) {
|
||||
this.data.items.sort((a, b) => a.order - b.order);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user