Fix Delete button not showing in collection modal (#7304)

This commit is contained in:
Thomas Rittson 2023-12-29 09:54:00 +10:00 committed by GitHub
parent 163aab202b
commit 63384bead9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 8 deletions

View File

@ -109,7 +109,7 @@
{{ "cancel" | i18n }} {{ "cancel" | i18n }}
</button> </button>
<button <button
*ngIf="canDelete$ | async" *ngIf="showDeleteButton"
type="button" type="button"
bitIconButton="bwi-trash" bitIconButton="bwi-trash"
buttonType="danger" buttonType="danger"

View File

@ -94,6 +94,7 @@ export class CollectionDialogComponent implements OnInit, OnDestroy {
selectedOrg: "", selectedOrg: "",
}); });
protected PermissionMode = PermissionMode; protected PermissionMode = PermissionMode;
protected showDeleteButton = false;
constructor( constructor(
@Inject(DIALOG_DATA) private params: CollectionDialogParams, @Inject(DIALOG_DATA) private params: CollectionDialogParams,
@ -198,6 +199,8 @@ export class CollectionDialogComponent implements OnInit, OnDestroy {
parent, parent,
access: accessSelections, access: accessSelections,
}); });
this.showDeleteButton = this.collection.canDelete(organization, flexibleCollections);
} else { } else {
this.nestOptions = collections; this.nestOptions = collections;
const parent = collections.find((c) => c.id === this.params.parentCollectionId); const parent = collections.find((c) => c.id === this.params.parentCollectionId);
@ -313,13 +316,6 @@ export class CollectionDialogComponent implements OnInit, OnDestroy {
this.close(CollectionDialogAction.Deleted, this.collection); this.close(CollectionDialogAction.Deleted, this.collection);
}; };
protected canDelete$ = this.flexibleCollectionsEnabled$.pipe(
map(
(flexibleCollectionsEnabled) =>
this.editMode && this.collection.canDelete(this.organization, flexibleCollectionsEnabled),
),
);
ngOnDestroy(): void { ngOnDestroy(): void {
this.destroy$.next(); this.destroy$.next();
this.destroy$.complete(); this.destroy$.complete();