Swap ngx-clipboard for Angular CDK

This commit is contained in:
shamoon 2023-10-10 23:53:53 -07:00
parent 9170b26354
commit 66e2d83ea0
6 changed files with 14 additions and 44 deletions

View File

@ -26,7 +26,6 @@
"file-saver": "^2.0.5",
"mime-names": "^1.0.0",
"ng2-pdf-viewer": "^10.0.0",
"ngx-clipboard": "^16.0.0",
"ngx-color": "^9.0.0",
"ngx-cookie-service": "^16.0.1",
"ngx-file-drop": "^16.0.0",
@ -14089,19 +14088,6 @@
"pdfjs-dist": "~2.16.105"
}
},
"node_modules/ngx-clipboard": {
"version": "16.0.0",
"resolved": "https://registry.npmjs.org/ngx-clipboard/-/ngx-clipboard-16.0.0.tgz",
"integrity": "sha512-rZ/Eo1PqiKMiyF8tdjhmUkoUu68f7OzBJ7YH1YFeh2RAaNrerTaW8XfFOzppSckjFQqA1fwGSYuTTJlDhDag5w==",
"dependencies": {
"ngx-window-token": ">=7.0.0",
"tslib": "^2.0.0"
},
"peerDependencies": {
"@angular/common": ">=13.0.0",
"@angular/core": ">=13.0.0"
}
},
"node_modules/ngx-color": {
"version": "9.0.0",
"resolved": "https://registry.npmjs.org/ngx-color/-/ngx-color-9.0.0.tgz",
@ -14172,21 +14158,6 @@
"@ng-bootstrap/ng-bootstrap": "^15.0.0"
}
},
"node_modules/ngx-window-token": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/ngx-window-token/-/ngx-window-token-7.0.0.tgz",
"integrity": "sha512-5+XfRVSY7Dciu8xyCNMkOlH2UfwR9W2P1Pirz7caaZgOZDjFbL8aEO2stjfJJm2FFf1D6dlVHNzhLWGk9HGkqA==",
"dependencies": {
"tslib": "^2.0.0"
},
"engines": {
"node": "^14.20.0 || ^16.13.0 || >=18.10.0"
},
"peerDependencies": {
"@angular/common": ">=13.0.0",
"@angular/core": ">=13.0.0"
}
},
"node_modules/nice-napi": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/nice-napi/-/nice-napi-1.0.2.tgz",

View File

@ -28,7 +28,6 @@
"file-saver": "^2.0.5",
"mime-names": "^1.0.0",
"ng2-pdf-viewer": "^10.0.0",
"ngx-clipboard": "^16.0.0",
"ngx-color": "^9.0.0",
"ngx-cookie-service": "^16.0.1",
"ngx-file-drop": "^16.0.0",

View File

@ -18,7 +18,7 @@ import { ShareLinkService } from 'src/app/services/rest/share-link.service'
import { ToastService } from 'src/app/services/toast.service'
import { environment } from 'src/environments/environment'
import { ShareLinksDropdownComponent } from './share-links-dropdown.component'
import { ClipboardService } from 'ngx-clipboard'
import { Clipboard } from '@angular/cdk/clipboard'
describe('ShareLinksDropdownComponent', () => {
let component: ShareLinksDropdownComponent
@ -26,7 +26,7 @@ describe('ShareLinksDropdownComponent', () => {
let shareLinkService: ShareLinkService
let toastService: ToastService
let httpController: HttpTestingController
let clipboardService: ClipboardService
let clipboard: Clipboard
beforeEach(() => {
TestBed.configureTestingModule({
@ -38,7 +38,7 @@ describe('ShareLinksDropdownComponent', () => {
shareLinkService = TestBed.inject(ShareLinkService)
toastService = TestBed.inject(ToastService)
httpController = TestBed.inject(HttpTestingController)
clipboardService = TestBed.inject(ClipboardService)
clipboard = TestBed.inject(Clipboard)
component = fixture.componentInstance
fixture.detectChanges()
@ -102,7 +102,7 @@ describe('ShareLinksDropdownComponent', () => {
const expiration = new Date()
expiration.setDate(expiration.getDate() + 7)
const copySpy = jest.spyOn(clipboardService, 'copy')
const copySpy = jest.spyOn(clipboard, 'copy')
const refreshSpy = jest.spyOn(component, 'refresh')
component.createLink()

View File

@ -7,7 +7,7 @@ import {
import { ShareLinkService } from 'src/app/services/rest/share-link.service'
import { ToastService } from 'src/app/services/toast.service'
import { environment } from 'src/environments/environment'
import { ClipboardService } from 'ngx-clipboard'
import { Clipboard } from '@angular/cdk/clipboard'
@Component({
selector: 'pngx-share-links-dropdown',
@ -51,7 +51,7 @@ export class ShareLinksDropdownComponent implements OnInit {
constructor(
private shareLinkService: ShareLinkService,
private toastService: ToastService,
private clipboardService: ClipboardService
private clipboard: Clipboard
) {}
ngOnInit(): void {
@ -91,7 +91,7 @@ export class ShareLinksDropdownComponent implements OnInit {
}
copy(link: PaperlessShareLink) {
this.clipboardService.copy(this.getShareUrl(link))
this.clipboard.copy(this.getShareUrl(link))
this.copied = link.id
setTimeout(() => {
this.copied = null

View File

@ -10,7 +10,7 @@ import { ComponentFixture } from '@angular/core/testing'
import { HttpClientTestingModule } from '@angular/common/http/testing'
import { of } from 'rxjs'
import { NgbModule } from '@ng-bootstrap/ng-bootstrap'
import { ClipboardService } from 'ngx-clipboard'
import { Clipboard } from '@angular/cdk/clipboard'
const toasts = [
{
@ -42,7 +42,7 @@ describe('ToastsComponent', () => {
let component: ToastsComponent
let fixture: ComponentFixture<ToastsComponent>
let toastService: ToastService
let clipboardService: ClipboardService
let clipboard: Clipboard
beforeEach(async () => {
TestBed.configureTestingModule({
@ -60,7 +60,7 @@ describe('ToastsComponent', () => {
fixture = TestBed.createComponent(ToastsComponent)
toastService = TestBed.inject(ToastService)
clipboardService = TestBed.inject(ClipboardService)
clipboard = TestBed.inject(Clipboard)
component = fixture.componentInstance
@ -117,7 +117,7 @@ describe('ToastsComponent', () => {
'Error 2 message details'
)
const copySpy = jest.spyOn(clipboardService, 'copy')
const copySpy = jest.spyOn(clipboard, 'copy')
component.copyError(toasts[2].error)
expect(copySpy).toHaveBeenCalled()

View File

@ -1,7 +1,7 @@
import { Component, OnDestroy, OnInit } from '@angular/core'
import { Subscription } from 'rxjs'
import { Toast, ToastService } from 'src/app/services/toast.service'
import { ClipboardService } from 'ngx-clipboard'
import { Clipboard } from '@angular/cdk/clipboard'
@Component({
selector: 'pngx-toasts',
@ -11,7 +11,7 @@ import { ClipboardService } from 'ngx-clipboard'
export class ToastsComponent implements OnInit, OnDestroy {
constructor(
private toastService: ToastService,
private clipboardService: ClipboardService
private clipboard: Clipboard
) {}
private subscription: Subscription
@ -49,7 +49,7 @@ export class ToastsComponent implements OnInit, OnDestroy {
}
public copyError(error: any) {
this.clipboardService.copy(JSON.stringify(error))
this.clipboard.copy(JSON.stringify(error))
this.copied = true
setTimeout(() => {
this.copied = false