Skip to content

Commit

Permalink
chore: restore edit button (#28307)
Browse files Browse the repository at this point in the history
  • Loading branch information
rjvelazco authored Apr 19, 2024
1 parent 9e49acb commit 624c7a5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ describe('DotBinaryFieldPreviewComponent', () => {
);
});

it('should be editable', () => {
spectator.detectChanges();
const editButton = spectator.query(byTestId('edit-button'));
expect(editButton).toBeTruthy();
});

it('should show download button responsive', () => {
spectator.detectChanges();
const downloadButtonResponsive = spectator.query(byTestId('download-btn-responsive'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,17 @@ export class DotBinaryFieldPreviewComponent implements OnInit, OnChanges {
}

ngOnInit() {
this.isEditable = this.metadata.editableAsText || this.isEditableImage();
if (this.contentlet) {
this.content.set(this.contentlet?.content);
this.fetchResourceLinks();
}
}

ngOnChanges({ tempFile }: SimpleChanges): void {
ngOnChanges({ tempFile, editableImage }: SimpleChanges): void {
if (editableImage) {
this.isEditable = this.isFileEditable();
}

if (tempFile?.currentValue) {
this.content.set(tempFile.currentValue.content);
}
Expand Down Expand Up @@ -190,7 +193,17 @@ export class DotBinaryFieldPreviewComponent implements OnInit, OnChanges {
}

/**
* Emits event to remove the file
* Check if the file is editable
*
* @return {*} {boolean}
* @memberof DotBinaryFieldPreviewComponent
*/
private isFileEditable(): boolean {
return this.metadata.editableAsText || this.isEditableImage();
}

/**
* Check if the file is an editable image
*
* @private
* @return {*} {boolean}
Expand Down

0 comments on commit 624c7a5

Please sign in to comment.