accessibility (#1689)

This commit is contained in:
Cilibiu Bogdan
2020-09-25 12:58:49 +03:00
committed by GitHub
parent 85a2d7db5c
commit 29f2f67491
3 changed files with 21 additions and 4 deletions

View File

@@ -17,10 +17,8 @@
mat-icon-button mat-icon-button
data-automation-id="share-action-button" data-automation-id="share-action-button"
(click)="editSharedNode(selection)" (click)="editSharedNode(selection)"
[attr.title]=" [attr.aria-label]="getLabel(selection) | translate"
(isShared(selection) ? 'APP.ACTIONS.SHARE_EDIT' : 'APP.ACTIONS.SHARE') [attr.title]="getLabel(selection) | translate"
| translate
"
> >
<mat-icon>link</mat-icon> <mat-icon>link</mat-icon>
</button> </button>

View File

@@ -72,4 +72,19 @@ describe('ToggleSharedComponent', () => {
component.editSharedNode({ first: { entry } }); component.editSharedNode({ first: { entry } });
expect(storeMock.dispatch).toHaveBeenCalled(); expect(storeMock.dispatch).toHaveBeenCalled();
}); });
it('should get action label for unshared file', () => {
component.ngOnInit();
const label = component.getLabel({ first: { entry } });
expect(label).toBe('APP.ACTIONS.SHARE');
});
it('should get action label for shared file', () => {
entry.properties['qshare:sharedId'] = 'some-id';
component.ngOnInit();
const label = component.getLabel({ first: { entry } });
expect(label).toBe('APP.ACTIONS.SHARE_EDIT');
});
}); });

View File

@@ -56,4 +56,8 @@ export class ToggleSharedComponent implements OnInit {
editSharedNode(selection: SelectionState) { editSharedNode(selection: SelectionState) {
this.store.dispatch(new ShareNodeAction(selection.first)); this.store.dispatch(new ShareNodeAction(selection.first));
} }
getLabel(selection: SelectionState): string {
return this.isShared(selection) ? 'APP.ACTIONS.SHARE_EDIT' : 'APP.ACTIONS.SHARE';
}
} }