Browse Source

Add snack bar

pull/4175/head
Thomas Kaul 8 months ago
parent
commit
d34284689a
  1. 2
      apps/client/src/app/components/access-table/access-table.component.html
  2. 14
      apps/client/src/app/components/access-table/access-table.component.ts

2
apps/client/src/app/components/access-table/access-table.component.html

@ -66,7 +66,7 @@
</button> </button>
<mat-menu #transactionMenu="matMenu" xPosition="before"> <mat-menu #transactionMenu="matMenu" xPosition="before">
@if (element.type === 'PUBLIC') { @if (element.type === 'PUBLIC') {
<button mat-menu-item (click)="onCopyToClipboard(element.id)"> <button mat-menu-item (click)="onCopyUrlToClipboard(element.id)">
<ng-container i18n>Copy link to clipboard</ng-container> <ng-container i18n>Copy link to clipboard</ng-container>
</button> </button>
<hr class="my-0" /> <hr class="my-0" />

14
apps/client/src/app/components/access-table/access-table.component.ts

@ -12,6 +12,7 @@ import {
OnChanges, OnChanges,
Output Output
} from '@angular/core'; } from '@angular/core';
import { MatSnackBar } from '@angular/material/snack-bar';
import { MatTableDataSource } from '@angular/material/table'; import { MatTableDataSource } from '@angular/material/table';
@Component({ @Component({
@ -34,7 +35,8 @@ export class AccessTableComponent implements OnChanges {
public constructor( public constructor(
private clipboard: Clipboard, private clipboard: Clipboard,
private notificationService: NotificationService private notificationService: NotificationService,
private snackBar: MatSnackBar
) {} ) {}
public ngOnChanges() { public ngOnChanges() {
@ -55,8 +57,16 @@ export class AccessTableComponent implements OnChanges {
return `${this.baseUrl}/${languageCode}/p/${aId}`; return `${this.baseUrl}/${languageCode}/p/${aId}`;
} }
public onCopyToClipboard(aId: string): void { public onCopyUrlToClipboard(aId: string): void {
this.clipboard.copy(this.getPublicUrl(aId)); this.clipboard.copy(this.getPublicUrl(aId));
this.snackBar.open(
'✅ ' + $localize`Link has been copied to the clipboard`,
undefined,
{
duration: 3000
}
);
} }
public onDeleteAccess(aId: string) { public onDeleteAccess(aId: string) {

Loading…
Cancel
Save