diff --git a/src-ui/src/app/components/common/share-links-dropdown/share-links-dropdown.component.spec.ts b/src-ui/src/app/components/common/share-links-dropdown/share-links-dropdown.component.spec.ts
index 27955a8a5..0b7284383 100644
--- a/src-ui/src/app/components/common/share-links-dropdown/share-links-dropdown.component.spec.ts
+++ b/src-ui/src/app/components/common/share-links-dropdown/share-links-dropdown.component.spec.ts
@@ -19,6 +19,7 @@ import { ToastService } from 'src/app/services/toast.service'
import { environment } from 'src/environments/environment'
import { ShareLinksDropdownComponent } from './share-links-dropdown.component'
import { Clipboard } from '@angular/cdk/clipboard'
+import { By } from '@angular/platform-browser'
describe('ShareLinksDropdownComponent', () => {
let component: ShareLinksDropdownComponent
@@ -88,7 +89,7 @@ describe('ShareLinksDropdownComponent', () => {
.mockReturnValueOnce(throwError(() => new Error('Unable to get links')))
component.documentId = 99
- component.refresh()
+ component.ngOnInit()
fixture.detectChanges()
expect(toastSpy).toHaveBeenCalled()
})
@@ -97,12 +98,13 @@ describe('ShareLinksDropdownComponent', () => {
const createSpy = jest.spyOn(shareLinkService, 'createLinkForDocument')
component.documentId = 99
component.expirationDays = 7
- component.archiveVersion = false
+ component.useArchiveVersion = false
const expiration = new Date()
expiration.setDate(expiration.getDate() + 7)
const copySpy = jest.spyOn(clipboard, 'copy')
+ copySpy.mockReturnValue(true)
const refreshSpy = jest.spyOn(component, 'refresh')
component.createLink()
@@ -117,8 +119,10 @@ describe('ShareLinksDropdownComponent', () => {
fixture.detectChanges()
tick(3000)
- expect(copySpy).toHaveBeenCalled()
expect(refreshSpy).toHaveBeenCalled()
+ expect(copySpy).toHaveBeenCalled()
+ expect(component.copied).toEqual(1)
+ tick(100) // copy timeout
}))
it('should show error on link creation if needed', () => {
@@ -212,4 +216,16 @@ describe('ShareLinksDropdownComponent', () => {
'http://example.domainwithapiinit.com:1234/subpath/share/123abc123'
)
})
+
+ it('should disable archive switch & option if no archive available', () => {
+ component.hasArchiveVersion = false
+ component.ngOnInit()
+ fixture.detectChanges()
+ expect(component.useArchiveVersion).toBeFalsy()
+ expect(
+ fixture.debugElement.query(By.css("input[type='checkbox']")).attributes[
+ 'ng-reflect-is-disabled'
+ ]
+ ).toBeTruthy()
+ })
})
diff --git a/src-ui/src/app/components/common/share-links-dropdown/share-links-dropdown.component.ts b/src-ui/src/app/components/common/share-links-dropdown/share-links-dropdown.component.ts
index fa2df3a54..cce951ba2 100644
--- a/src-ui/src/app/components/common/share-links-dropdown/share-links-dropdown.component.ts
+++ b/src-ui/src/app/components/common/share-links-dropdown/share-links-dropdown.component.ts
@@ -38,6 +38,9 @@ export class ShareLinksDropdownComponent implements OnInit {
@Input()
disabled: boolean = false
+ @Input()
+ hasArchiveVersion: boolean = true
+
shareLinks: PaperlessShareLink[]
loading: boolean = false
@@ -46,7 +49,7 @@ export class ShareLinksDropdownComponent implements OnInit {
expirationDays: number = 7
- archiveVersion: boolean = true
+ useArchiveVersion: boolean = true
constructor(
private shareLinkService: ShareLinkService,
@@ -56,6 +59,7 @@ export class ShareLinksDropdownComponent implements OnInit {
ngOnInit(): void {
if (this._documentId !== undefined) this.refresh()
+ this.useArchiveVersion = this.hasArchiveVersion
}
refresh() {
@@ -94,11 +98,13 @@ export class ShareLinksDropdownComponent implements OnInit {
}
copy(link: PaperlessShareLink) {
- this.clipboard.copy(this.getShareUrl(link))
- this.copied = link.id
- setTimeout(() => {
- this.copied = null
- }, 3000)
+ const success = this.clipboard.copy(this.getShareUrl(link))
+ if (success) {
+ this.copied = link.id
+ setTimeout(() => {
+ this.copied = null
+ }, 3000)
+ }
}
canShare(link: PaperlessShareLink): boolean {
@@ -132,7 +138,7 @@ export class ShareLinksDropdownComponent implements OnInit {
this.shareLinkService
.createLinkForDocument(
this._documentId,
- this.archiveVersion
+ this.useArchiveVersion
? PaperlessFileVersion.Archive
: PaperlessFileVersion.Original,
expiration
@@ -140,7 +146,9 @@ export class ShareLinksDropdownComponent implements OnInit {
.subscribe({
next: (result) => {
this.loading = false
- this.copy(result)
+ setTimeout(() => {
+ this.copy(result)
+ }, 10)
this.refresh()
},
error: (e) => {
diff --git a/src-ui/src/app/components/document-detail/document-detail.component.html b/src-ui/src/app/components/document-detail/document-detail.component.html
index ea14b750d..aa2f91a35 100644
--- a/src-ui/src/app/components/document-detail/document-detail.component.html
+++ b/src-ui/src/app/components/document-detail/document-detail.component.html
@@ -69,7 +69,7 @@
(added)="addField($event)">
-
+
diff --git a/src-ui/src/app/data/paperless-document.ts b/src-ui/src/app/data/paperless-document.ts
index b00c478fc..8071e2b45 100644
--- a/src-ui/src/app/data/paperless-document.ts
+++ b/src-ui/src/app/data/paperless-document.ts
@@ -50,6 +50,8 @@ export interface PaperlessDocument extends ObjectWithPermissions {
original_file_name?: string
+ archived_file_name?: string
+
download_url?: string
thumbnail_url?: string