mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-5355] - Fix attach button visibility when using external source (#6784)
This commit is contained in:
@@ -33,7 +33,7 @@
|
||||
|
||||
<button *ngIf="isLoggedIn()"
|
||||
mat-button
|
||||
[disabled]="!chosenNode"
|
||||
[disabled]="!hasNodeSelected()"
|
||||
class="adf-choose-action"
|
||||
(click)="onClick()"
|
||||
data-automation-id="attach-file-dialog-actions-choose">{{ buttonActionName | translate }}
|
||||
|
@@ -209,4 +209,42 @@ describe('AttachFileWidgetDialogComponent', () => {
|
||||
expect(matDialogRef.close).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Attach button', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
isLogged = true;
|
||||
}));
|
||||
|
||||
it('should be disabled by default', () => {
|
||||
fixture.detectChanges();
|
||||
const actionButton = fixture.debugElement.query(By.css('[data-automation-id="attach-file-dialog-actions-choose"]'));
|
||||
|
||||
expect(actionButton.nativeElement.disabled).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should be enabled when a node is chosen', () => {
|
||||
widget.onSelect([new Node({ id: 'fake' })]);
|
||||
fixture.detectChanges();
|
||||
const actionButton = fixture.debugElement.query(By.css('[data-automation-id="attach-file-dialog-actions-choose"]'));
|
||||
|
||||
expect(actionButton.nativeElement.disabled).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should be disabled when no node chosen', () => {
|
||||
widget.onSelect([new Node({ id: 'fake' })]);
|
||||
fixture.detectChanges();
|
||||
|
||||
const actionButtonWithNodeSelected = fixture.debugElement.query(By.css('[data-automation-id="attach-file-dialog-actions-choose"]'));
|
||||
|
||||
expect(actionButtonWithNodeSelected.nativeElement.disabled).toBe(false);
|
||||
|
||||
widget.onSelect([]);
|
||||
fixture.detectChanges();
|
||||
|
||||
const actionButtonWithoutNodeSelected = fixture.debugElement.query(By.css('[data-automation-id="attach-file-dialog-actions-choose"]'));
|
||||
|
||||
expect(actionButtonWithoutNodeSelected.nativeElement.disabled).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -105,4 +105,8 @@ export class AttachFileWidgetDialogComponent {
|
||||
getTitleTranslation(action: string, name?: string): string {
|
||||
return this.translation.instant(`ATTACH-FILE.ACTIONS.${action}_ITEM`, { name: this.translation.instant(name) });
|
||||
}
|
||||
|
||||
hasNodeSelected(): boolean {
|
||||
return this.chosenNode?.length > 0;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user