Skip to content

Commit f317374

Browse files
authored
[ACS-10306] Proper alt for user or group icons (#11403)
* [ACS-10306] Proper alt for user or group icons * [ACS-10306] CR fix
1 parent a9efe36 commit f317374

File tree

4 files changed

+38
-19
lines changed

4 files changed

+38
-19
lines changed

.github/workflows/git-tag.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ env:
2222
LOG_LEVEL: "ERROR"
2323
NODE_OPTIONS: "--max-old-space-size=5120"
2424
NPM_REGISTRY_ADDRESS: ${{ secrets.NPM_REGISTRY_ADDRESS }}
25-
NPM_REGISTRY_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }}
2625
BOT_GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
2726

2827
jobs:

lib/content-services/src/lib/i18n/en.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,10 @@
612612
"NOT-ALLOWED": "You are not allowed to change permissions"
613613
}
614614
},
615+
"USER_ICON": {
616+
"GROUP_ICON_ALT": "Group icon",
617+
"GROUP_USER_SELECTED_ALT": "Selected group or user icon"
618+
},
615619
"ADF-TREE-VIEW": {
616620
"MISSING-ID": "No nodeId provided!",
617621
"ACCESSIBILITY": {

lib/content-services/src/lib/permission-manager/components/user-icon-column/user-icon-column.component.spec.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
1919
import { ContentTestingModule } from '../../../testing/content.testing.module';
2020
import { UserIconColumnComponent } from './user-icon-column.component';
2121
import { NodeEntry } from '@alfresco/js-api';
22+
import { UnitTestingUtils } from '@alfresco/adf-core';
23+
import { DebugElement } from '@angular/core';
2224

2325
describe('UserIconColumnComponent', () => {
2426
let fixture: ComponentFixture<UserIconColumnComponent>;
2527
let component: UserIconColumnComponent;
26-
let element: HTMLElement;
28+
let testingUtils: UnitTestingUtils;
2729
const person = {
2830
firstName: 'fake',
2931
lastName: 'user',
@@ -35,18 +37,20 @@ describe('UserIconColumnComponent', () => {
3537
displayName: 'fake authority'
3638
};
3739

40+
const getVisuallyHiddenText = (): string => testingUtils.getInnerTextByCSS('.cdk-visually-hidden');
41+
3842
beforeEach(() => {
3943
TestBed.configureTestingModule({
4044
imports: [ContentTestingModule]
4145
});
4246
fixture = TestBed.createComponent(UserIconColumnComponent);
4347
component = fixture.componentInstance;
44-
element = fixture.nativeElement;
48+
testingUtils = new UnitTestingUtils(fixture.debugElement);
4549
fixture.detectChanges();
4650
});
4751

4852
describe('person initial', () => {
49-
const getInitials = () => element.querySelector('[data-automation-id="user-initials-image"]')?.textContent;
53+
const getInitials = (): string => testingUtils.getInnerTextByDataAutomationId('user-initials-image');
5054

5155
it('should render person value from context', () => {
5256
component.context = {
@@ -58,7 +62,7 @@ describe('UserIconColumnComponent', () => {
5862
};
5963
component.ngOnInit();
6064
fixture.detectChanges();
61-
expect(getInitials()).toContain('fu');
65+
expect(getInitials()).toContain('FU');
6266
});
6367

6468
it('should render person value from node', () => {
@@ -80,7 +84,7 @@ describe('UserIconColumnComponent', () => {
8084
});
8185

8286
describe('group initial', () => {
83-
const getGroupIcon = () => element.querySelector('[id="group-icon"] .adf-group-icon');
87+
const getGroupIcon = (): DebugElement => testingUtils.getByCSS('[id="group-icon"] .adf-group-icon');
8488

8589
it('should render group value from context', () => {
8690
component.context = {
@@ -93,7 +97,8 @@ describe('UserIconColumnComponent', () => {
9397
component.ngOnInit();
9498
fixture.detectChanges();
9599
expect(getGroupIcon()).toBeDefined();
96-
expect(getGroupIcon().textContent).toContain('people_alt_outline');
100+
expect(getGroupIcon().nativeElement.textContent).toContain('people_alt_outline');
101+
expect(getVisuallyHiddenText()).toBe('USER_ICON.GROUP_ICON_ALT');
97102
});
98103

99104
it('should render person value from node', () => {
@@ -108,15 +113,17 @@ describe('UserIconColumnComponent', () => {
108113
component.ngOnInit();
109114
fixture.detectChanges();
110115
expect(getGroupIcon()).toBeDefined();
111-
expect(getGroupIcon().textContent).toContain('people_alt_outline');
116+
expect(getGroupIcon().nativeElement.textContent).toContain('people_alt_outline');
117+
expect(getVisuallyHiddenText()).toBe('USER_ICON.GROUP_ICON_ALT');
112118
});
113119
});
114120

115121
it('should render select icon', () => {
116122
component.selected = true;
117123
component.ngOnInit();
118124
fixture.detectChanges();
119-
expect(element.querySelector('.adf-people-select-icon[svgIcon="selected"]')).toBeDefined();
125+
expect(testingUtils.getByCSS('.adf-people-select-icon[svgIcon="selected"]')).toBeDefined();
126+
expect(getVisuallyHiddenText()).toBe('USER_ICON.GROUP_USER_SELECTED_ALT');
120127
expect(component.isSelected).toBe(true);
121128
});
122129
});

lib/content-services/src/lib/permission-manager/components/user-icon-column/user-icon-column.component.ts

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,29 @@ import { BehaviorSubject } from 'rxjs';
2222
import { NodePermissionService } from '../../services/node-permission.service';
2323
import { CommonModule } from '@angular/common';
2424
import { MatIconModule } from '@angular/material/icon';
25+
import { TranslatePipe } from '@ngx-translate/core';
2526

2627
@Component({
2728
selector: 'adf-user-icon-column',
28-
imports: [CommonModule, MatIconModule, InitialUsernamePipe],
29+
imports: [CommonModule, MatIconModule, InitialUsernamePipe, TranslatePipe],
2930
template: `
30-
<div class="adf-cell-value" [attr.id]="group ? 'group-icon' : 'person-icon'" *ngIf="!isSelected">
31-
<ng-container *ngIf="displayText$ | async as user">
32-
<mat-icon *ngIf="group" class="adf-group-icon">people_alt_outline</mat-icon>
33-
<div *ngIf="!group" [outerHTML]="user | usernameInitials : 'adf-people-initial'"></div>
34-
</ng-container>
35-
</div>
36-
<div class="adf-cell-value" *ngIf="isSelected">
37-
<mat-icon class="adf-people-select-icon adf-datatable-selected" svgIcon="selected" />
38-
</div>
31+
@if (!isSelected) {
32+
<div class="adf-cell-value" [attr.id]="group ? 'group-icon' : 'person-icon'">
33+
@if (displayText$ | async; as user) {
34+
@if (group) {
35+
<mat-icon class="adf-group-icon">people_alt_outline</mat-icon>
36+
<span class="cdk-visually-hidden">{{ 'USER_ICON.GROUP_ICON_ALT' | translate }}</span>
37+
} @else {
38+
<div [outerHTML]="user | usernameInitials: 'adf-people-initial'"></div>
39+
}
40+
}
41+
</div>
42+
} @else {
43+
<div class="adf-cell-value">
44+
<mat-icon class="adf-people-select-icon adf-datatable-selected" svgIcon="selected" />
45+
<span class="cdk-visually-hidden">{{ 'USER_ICON.GROUP_USER_SELECTED_ALT' | translate }}</span>
46+
</div>
47+
}
3948
`,
4049
styleUrls: ['./user-icon-column.component.scss'],
4150
encapsulation: ViewEncapsulation.None,

0 commit comments

Comments
 (0)