mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
AAE-22467 Add tooltip on datatable row context menu list (#9682)
Co-authored-by: Diogo Bastos <50139916+DiogoABastos@users.noreply.github.com>
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
[attr.data-automation-id]="'context-' + (link.title || link.model?.title | translate)"
|
[attr.data-automation-id]="'context-' + (link.title || link.model?.title | translate)"
|
||||||
mat-menu-item
|
mat-menu-item
|
||||||
[disabled]="link.model?.disabled"
|
[disabled]="link.model?.disabled"
|
||||||
|
[matTooltip]="link.model?.tooltip | translate"
|
||||||
(click)="onMenuItemClick($event, link)">
|
(click)="onMenuItemClick($event, link)">
|
||||||
<mat-icon *ngIf="link.model?.icon">{{ link.model.icon }}</mat-icon>
|
<mat-icon *ngIf="link.model?.icon">{{ link.model.icon }}</mat-icon>
|
||||||
<span>{{ link.title || link.model?.title | translate }}</span>
|
<span>{{ link.title || link.model?.title | translate }}</span>
|
||||||
|
@@ -26,6 +26,7 @@ import { TranslateModule } from '@ngx-translate/core';
|
|||||||
import { contextMenuAnimation } from './animations';
|
import { contextMenuAnimation } from './animations';
|
||||||
import { ContextMenuOverlayRef } from './context-menu-overlay';
|
import { ContextMenuOverlayRef } from './context-menu-overlay';
|
||||||
import { CONTEXT_MENU_DATA } from './context-menu.tokens';
|
import { CONTEXT_MENU_DATA } from './context-menu.tokens';
|
||||||
|
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'adf-context-menu',
|
selector: 'adf-context-menu',
|
||||||
@@ -36,7 +37,7 @@ import { CONTEXT_MENU_DATA } from './context-menu.tokens';
|
|||||||
class: 'adf-context-menu'
|
class: 'adf-context-menu'
|
||||||
},
|
},
|
||||||
encapsulation: ViewEncapsulation.None,
|
encapsulation: ViewEncapsulation.None,
|
||||||
imports: [MatIconModule, MatMenuModule, NgForOf, NgIf, TranslateModule],
|
imports: [MatIconModule, MatMenuModule, MatTooltipModule, NgForOf, NgIf, TranslateModule],
|
||||||
animations: [trigger('panelAnimation', contextMenuAnimation)]
|
animations: [trigger('panelAnimation', contextMenuAnimation)]
|
||||||
})
|
})
|
||||||
export class ContextMenuListComponent implements AfterViewInit {
|
export class ContextMenuListComponent implements AfterViewInit {
|
||||||
|
@@ -21,6 +21,7 @@ import { ContextMenuModule } from './context-menu.module';
|
|||||||
import { CoreTestingModule } from '../testing/core.testing.module';
|
import { CoreTestingModule } from '../testing/core.testing.module';
|
||||||
import { HarnessLoader } from '@angular/cdk/testing';
|
import { HarnessLoader } from '@angular/cdk/testing';
|
||||||
import { MatIconHarness } from '@angular/material/icon/testing';
|
import { MatIconHarness } from '@angular/material/icon/testing';
|
||||||
|
import { MatTooltipHarness } from '@angular/material/tooltip/testing';
|
||||||
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
|
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -75,6 +76,29 @@ describe('ContextMenuDirective', () => {
|
|||||||
subject: {
|
subject: {
|
||||||
next: jasmine.createSpy('next')
|
next: jasmine.createSpy('next')
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
model: {
|
||||||
|
visible: true,
|
||||||
|
disabled: false,
|
||||||
|
title: 'action-5',
|
||||||
|
icon: 'action-icon-5',
|
||||||
|
tooltip: 'Action 5 tooltip'
|
||||||
|
},
|
||||||
|
subject: {
|
||||||
|
next: jasmine.createSpy('next')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
model: {
|
||||||
|
visible: true,
|
||||||
|
disabled: false,
|
||||||
|
title: 'action-6',
|
||||||
|
icon: 'action-icon-6'
|
||||||
|
},
|
||||||
|
subject: {
|
||||||
|
next: jasmine.createSpy('next')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -134,7 +158,7 @@ describe('ContextMenuDirective', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should not render item with visibility property set to false', () => {
|
it('should not render item with visibility property set to false', () => {
|
||||||
expect(contextMenu?.querySelectorAll('button').length).toBe(3);
|
expect(contextMenu?.querySelectorAll('button').length).toBe(5);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render item as disabled when `disabled` property is set to true', async () => {
|
it('should render item as disabled when `disabled` property is set to true', async () => {
|
||||||
@@ -173,5 +197,27 @@ describe('ContextMenuDirective', () => {
|
|||||||
).length
|
).length
|
||||||
).toBe(0);
|
).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should show tooltip if is set', async () => {
|
||||||
|
const expectedTooltipText = 'Action 5 tooltip';
|
||||||
|
const tooltip = await loader.getHarness(
|
||||||
|
MatTooltipHarness.with({
|
||||||
|
selector: '[data-automation-id="context-action-5"]'
|
||||||
|
})
|
||||||
|
);
|
||||||
|
await tooltip.show();
|
||||||
|
expect(await tooltip.isOpen()).toBeTrue();
|
||||||
|
expect(await tooltip.getTooltipText()).toEqual(expectedTooltipText);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not show tooltip if is not set', async () => {
|
||||||
|
const tooltip = await loader.getHarness(
|
||||||
|
MatTooltipHarness.with({
|
||||||
|
selector: '[data-automation-id="context-action-6"]'
|
||||||
|
})
|
||||||
|
);
|
||||||
|
await tooltip.show();
|
||||||
|
expect(await tooltip.isOpen()).toBeFalse();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user