mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-06 00:41:11 -06:00
Consistent naming to Share Link Bundle
This commit is contained in:
@@ -1,7 +0,0 @@
|
||||
describe('ShareBundleDialogComponent', () => {
|
||||
it('is pending implementation', () => {
|
||||
pending(
|
||||
'ShareBundleDialogComponent tests will be implemented once the dialog logic is finalized.'
|
||||
)
|
||||
})
|
||||
})
|
||||
@@ -1,7 +0,0 @@
|
||||
describe('ShareBundleManageDialogComponent', () => {
|
||||
it('is pending implementation', () => {
|
||||
pending(
|
||||
'ShareBundleManageDialogComponent tests will be implemented once the dialog logic is finalized.'
|
||||
)
|
||||
})
|
||||
})
|
||||
@@ -50,9 +50,9 @@
|
||||
} @else {
|
||||
<div class="d-flex flex-column gap-3">
|
||||
<div class="alert alert-success mb-0" role="status">
|
||||
<h6 class="alert-heading mb-1" i18n>Share link requested</h6>
|
||||
<h6 class="alert-heading mb-1" i18n>Share link bundle requested</h6>
|
||||
<p class="mb-0 small" i18n>
|
||||
You can copy the link below or open the management screen to monitor its progress. The link will start working once it is ready.
|
||||
You can copy the share link below or open the manager to monitor progress. The link will start working once the bundle is ready.
|
||||
</p>
|
||||
</div>
|
||||
<dl class="row mb-0 small">
|
||||
@@ -105,11 +105,11 @@
|
||||
<div class="modal-footer">
|
||||
<div class="d-flex align-items-center gap-2 w-100">
|
||||
<div class="text-light fst-italic small">
|
||||
<ng-container i18n>A zip file containing the selected documents will be created. This process happens in the background and may take some time, especially for large bundles.</ng-container>
|
||||
<ng-container i18n>A zip file containing the selected documents will be created for this share link bundle. This process happens in the background and may take some time, especially for large bundles.</ng-container>
|
||||
</div>
|
||||
<button type="button" class="btn btn-outline-secondary btn-sm ms-auto" (click)="cancel()">{{ cancelBtnCaption }}</button>
|
||||
@if (createdBundle) {
|
||||
<button type="button" class="btn btn-outline-secondary btn-sm" (click)="openManage()" i18n>Open manage links</button>
|
||||
<button type="button" class="btn btn-outline-secondary btn-sm" (click)="openManage()" i18n>Manage share link bundles</button>
|
||||
}
|
||||
|
||||
@if (!createdBundle) {
|
||||
@@ -0,0 +1,7 @@
|
||||
describe('ShareLinkBundleDialogComponent', () => {
|
||||
it('is pending implementation', () => {
|
||||
pending(
|
||||
'ShareLinkBundleDialogComponent tests will be implemented once the dialog logic is finalized.'
|
||||
)
|
||||
})
|
||||
})
|
||||
@@ -4,17 +4,17 @@ import { Component, Input, inject } from '@angular/core'
|
||||
import { FormBuilder, FormGroup, ReactiveFormsModule } from '@angular/forms'
|
||||
import { NgxBootstrapIconsModule } from 'ngx-bootstrap-icons'
|
||||
import { Document } from 'src/app/data/document'
|
||||
import {
|
||||
SHARE_BUNDLE_FILE_VERSION_LABELS,
|
||||
SHARE_BUNDLE_STATUS_LABELS,
|
||||
ShareBundleCreatePayload,
|
||||
ShareBundleStatus,
|
||||
ShareBundleSummary,
|
||||
} from 'src/app/data/share-bundle'
|
||||
import {
|
||||
FileVersion,
|
||||
SHARE_LINK_EXPIRATION_OPTIONS,
|
||||
} from 'src/app/data/share-link'
|
||||
import {
|
||||
SHARE_LINK_BUNDLE_FILE_VERSION_LABELS,
|
||||
SHARE_LINK_BUNDLE_STATUS_LABELS,
|
||||
ShareLinkBundleCreatePayload,
|
||||
ShareLinkBundleStatus,
|
||||
ShareLinkBundleSummary,
|
||||
} from 'src/app/data/share-link-bundle'
|
||||
import { DocumentTitlePipe } from 'src/app/pipes/document-title.pipe'
|
||||
import { FileSizePipe } from 'src/app/pipes/file-size.pipe'
|
||||
import { ToastService } from 'src/app/services/toast.service'
|
||||
@@ -22,8 +22,8 @@ import { environment } from 'src/environments/environment'
|
||||
import { ConfirmDialogComponent } from '../confirm-dialog/confirm-dialog.component'
|
||||
|
||||
@Component({
|
||||
selector: 'pngx-share-bundle-dialog',
|
||||
templateUrl: './share-bundle-dialog.component.html',
|
||||
selector: 'pngx-share-link-bundle-dialog',
|
||||
templateUrl: './share-link-bundle-dialog.component.html',
|
||||
imports: [
|
||||
CommonModule,
|
||||
ReactiveFormsModule,
|
||||
@@ -33,7 +33,7 @@ import { ConfirmDialogComponent } from '../confirm-dialog/confirm-dialog.compone
|
||||
],
|
||||
providers: [],
|
||||
})
|
||||
export class ShareBundleDialogComponent extends ConfirmDialogComponent {
|
||||
export class ShareLinkBundleDialogComponent extends ConfirmDialogComponent {
|
||||
private formBuilder = inject(FormBuilder)
|
||||
private clipboard = inject(Clipboard)
|
||||
private toastService = inject(ToastService)
|
||||
@@ -46,20 +46,20 @@ export class ShareBundleDialogComponent extends ConfirmDialogComponent {
|
||||
shareArchiveVersion: [true],
|
||||
expirationDays: [7],
|
||||
})
|
||||
payload: ShareBundleCreatePayload | null = null
|
||||
payload: ShareLinkBundleCreatePayload | null = null
|
||||
|
||||
readonly expirationOptions = SHARE_LINK_EXPIRATION_OPTIONS
|
||||
|
||||
createdBundle: ShareBundleSummary | null = null
|
||||
createdBundle: ShareLinkBundleSummary | null = null
|
||||
copied = false
|
||||
onOpenManage?: () => void
|
||||
readonly statuses = ShareBundleStatus
|
||||
readonly statuses = ShareLinkBundleStatus
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
this.loading = false
|
||||
this.title = $localize`Share Selected Documents`
|
||||
this.btnCaption = $localize`Create`
|
||||
this.title = $localize`Create share link bundle`
|
||||
this.btnCaption = $localize`Create link`
|
||||
}
|
||||
|
||||
@Input()
|
||||
@@ -82,14 +82,14 @@ export class ShareBundleDialogComponent extends ConfirmDialogComponent {
|
||||
super.confirm()
|
||||
}
|
||||
|
||||
getShareUrl(bundle: ShareBundleSummary): string {
|
||||
getShareUrl(bundle: ShareLinkBundleSummary): string {
|
||||
const apiURL = new URL(environment.apiBaseUrl)
|
||||
return `${apiURL.origin}${apiURL.pathname.replace(/\/api\/$/, '/share/')}${
|
||||
bundle.slug
|
||||
}`
|
||||
}
|
||||
|
||||
copy(bundle: ShareBundleSummary): void {
|
||||
copy(bundle: ShareLinkBundleSummary): void {
|
||||
const success = this.clipboard.copy(this.getShareUrl(bundle))
|
||||
if (success) {
|
||||
this.copied = true
|
||||
@@ -108,11 +108,11 @@ export class ShareBundleDialogComponent extends ConfirmDialogComponent {
|
||||
}
|
||||
}
|
||||
|
||||
statusLabel(status: ShareBundleSummary['status']): string {
|
||||
return SHARE_BUNDLE_STATUS_LABELS[status] ?? status
|
||||
statusLabel(status: ShareLinkBundleSummary['status']): string {
|
||||
return SHARE_LINK_BUNDLE_STATUS_LABELS[status] ?? status
|
||||
}
|
||||
|
||||
fileVersionLabel(version: FileVersion): string {
|
||||
return SHARE_BUNDLE_FILE_VERSION_LABELS[version] ?? version
|
||||
return SHARE_LINK_BUNDLE_FILE_VERSION_LABELS[version] ?? version
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
@if (loading) {
|
||||
<div class="d-flex align-items-center gap-2">
|
||||
<div class="spinner-border spinner-border-sm" role="status"></div>
|
||||
<span i18n>Loading bulk share links…</span>
|
||||
<span i18n>Loading share link bundles…</span>
|
||||
</div>
|
||||
}
|
||||
@if (!loading && error) {
|
||||
@@ -22,7 +22,7 @@
|
||||
</p>
|
||||
</div>
|
||||
@if (bundles.length === 0) {
|
||||
<p class="mb-0 text-muted fst-italic" i18n>No bulk share links currently exist.</p>
|
||||
<p class="mb-0 text-muted fst-italic" i18n>No share link bundles currently exist.</p>
|
||||
}
|
||||
@if (bundles.length > 0) {
|
||||
<div class="table-responsive">
|
||||
@@ -92,7 +92,7 @@
|
||||
@if (copiedSlug !== bundle.slug) {
|
||||
<i-bs name="clipboard"></i-bs>
|
||||
}
|
||||
<span class="visually-hidden" i18n>Copy link</span>
|
||||
<span class="visually-hidden" i18n>Copy share link</span>
|
||||
</button>
|
||||
@if (bundle.status === statuses.Failed) {
|
||||
<button
|
||||
@@ -112,7 +112,7 @@
|
||||
(click)="delete(bundle)"
|
||||
>
|
||||
<i-bs name="trash"></i-bs>
|
||||
<span class="visually-hidden" i18n>Delete link</span>
|
||||
<span class="visually-hidden" i18n>Delete share link bundle</span>
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
@@ -0,0 +1,7 @@
|
||||
describe('ShareLinkBundleManageDialogComponent', () => {
|
||||
it('is pending implementation', () => {
|
||||
pending(
|
||||
'ShareLinkBundleManageDialogComponent tests will be implemented once the dialog logic is finalized.'
|
||||
)
|
||||
})
|
||||
})
|
||||
@@ -4,40 +4,40 @@ import { Component, OnDestroy, OnInit, inject } from '@angular/core'
|
||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
|
||||
import { NgxBootstrapIconsModule } from 'ngx-bootstrap-icons'
|
||||
import { Subject, catchError, of, switchMap, takeUntil, timer } from 'rxjs'
|
||||
import {
|
||||
SHARE_BUNDLE_FILE_VERSION_LABELS,
|
||||
SHARE_BUNDLE_STATUS_LABELS,
|
||||
ShareBundleStatus,
|
||||
ShareBundleSummary,
|
||||
} from 'src/app/data/share-bundle'
|
||||
import { FileVersion } from 'src/app/data/share-link'
|
||||
import {
|
||||
SHARE_LINK_BUNDLE_FILE_VERSION_LABELS,
|
||||
SHARE_LINK_BUNDLE_STATUS_LABELS,
|
||||
ShareLinkBundleStatus,
|
||||
ShareLinkBundleSummary,
|
||||
} from 'src/app/data/share-link-bundle'
|
||||
import { FileSizePipe } from 'src/app/pipes/file-size.pipe'
|
||||
import { ShareBundleService } from 'src/app/services/rest/share-bundle.service'
|
||||
import { ShareLinkBundleService } from 'src/app/services/rest/share-link-bundle.service'
|
||||
import { ToastService } from 'src/app/services/toast.service'
|
||||
import { environment } from 'src/environments/environment'
|
||||
import { LoadingComponentWithPermissions } from '../../loading-component/loading.component'
|
||||
|
||||
@Component({
|
||||
selector: 'pngx-share-bundle-manage-dialog',
|
||||
templateUrl: './share-bundle-manage-dialog.component.html',
|
||||
selector: 'pngx-share-link-bundle-manage-dialog',
|
||||
templateUrl: './share-link-bundle-manage-dialog.component.html',
|
||||
imports: [CommonModule, NgxBootstrapIconsModule, FileSizePipe],
|
||||
})
|
||||
export class ShareBundleManageDialogComponent
|
||||
export class ShareLinkBundleManageDialogComponent
|
||||
extends LoadingComponentWithPermissions
|
||||
implements OnInit, OnDestroy
|
||||
{
|
||||
private activeModal = inject(NgbActiveModal)
|
||||
private shareBundleService = inject(ShareBundleService)
|
||||
private shareLinkBundleService = inject(ShareLinkBundleService)
|
||||
private toastService = inject(ToastService)
|
||||
private clipboard = inject(Clipboard)
|
||||
|
||||
title = $localize`Bulk Share Links`
|
||||
title = $localize`Share link bundles`
|
||||
|
||||
bundles: ShareBundleSummary[] = []
|
||||
bundles: ShareLinkBundleSummary[] = []
|
||||
error: string | null = null
|
||||
copiedSlug: string | null = null
|
||||
|
||||
readonly statuses = ShareBundleStatus
|
||||
readonly statuses = ShareLinkBundleStatus
|
||||
readonly fileVersions = FileVersion
|
||||
|
||||
private readonly refresh$ = new Subject<boolean>()
|
||||
@@ -50,14 +50,14 @@ export class ShareBundleManageDialogComponent
|
||||
this.loading = true
|
||||
}
|
||||
this.error = null
|
||||
return this.shareBundleService.listAllBundles().pipe(
|
||||
return this.shareLinkBundleService.listAllBundles().pipe(
|
||||
catchError((error) => {
|
||||
if (!silent) {
|
||||
this.loading = false
|
||||
}
|
||||
this.error = $localize`Failed to load bulk share links.`
|
||||
this.error = $localize`Failed to load share link bundles.`
|
||||
this.toastService.showError(
|
||||
$localize`Error retrieving bulk share links.`,
|
||||
$localize`Error retrieving share link bundles.`,
|
||||
error
|
||||
)
|
||||
return of(null)
|
||||
@@ -84,15 +84,15 @@ export class ShareBundleManageDialogComponent
|
||||
super.ngOnDestroy()
|
||||
}
|
||||
|
||||
getShareUrl(bundle: ShareBundleSummary): string {
|
||||
getShareUrl(bundle: ShareLinkBundleSummary): string {
|
||||
const apiURL = new URL(environment.apiBaseUrl)
|
||||
return `${apiURL.origin}${apiURL.pathname.replace(/\/api\/$/, '/share/')}${
|
||||
bundle.slug
|
||||
}`
|
||||
}
|
||||
|
||||
copy(bundle: ShareBundleSummary): void {
|
||||
if (bundle.status !== ShareBundleStatus.Ready) {
|
||||
copy(bundle: ShareLinkBundleSummary): void {
|
||||
if (bundle.status !== ShareLinkBundleStatus.Ready) {
|
||||
return
|
||||
}
|
||||
const success = this.clipboard.copy(this.getShareUrl(bundle))
|
||||
@@ -105,30 +105,30 @@ export class ShareBundleManageDialogComponent
|
||||
}
|
||||
}
|
||||
|
||||
delete(bundle: ShareBundleSummary): void {
|
||||
delete(bundle: ShareLinkBundleSummary): void {
|
||||
this.error = null
|
||||
this.loading = true
|
||||
this.shareBundleService.delete(bundle).subscribe({
|
||||
this.shareLinkBundleService.delete(bundle).subscribe({
|
||||
next: () => {
|
||||
this.toastService.showInfo($localize`Bulk share link deleted.`)
|
||||
this.toastService.showInfo($localize`Share link bundle deleted.`)
|
||||
this.triggerRefresh(false)
|
||||
},
|
||||
error: (e) => {
|
||||
this.loading = false
|
||||
this.toastService.showError(
|
||||
$localize`Error deleting bulk share link.`,
|
||||
$localize`Error deleting share link bundle.`,
|
||||
e
|
||||
)
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
retry(bundle: ShareBundleSummary): void {
|
||||
retry(bundle: ShareLinkBundleSummary): void {
|
||||
this.error = null
|
||||
this.shareBundleService.rebuildBundle(bundle.id).subscribe({
|
||||
this.shareLinkBundleService.rebuildBundle(bundle.id).subscribe({
|
||||
next: (updated) => {
|
||||
this.toastService.showInfo(
|
||||
$localize`Bulk share link rebuild requested.`
|
||||
$localize`Share link bundle rebuild requested.`
|
||||
)
|
||||
this.replaceBundle(updated)
|
||||
},
|
||||
@@ -138,19 +138,19 @@ export class ShareBundleManageDialogComponent
|
||||
})
|
||||
}
|
||||
|
||||
statusLabel(status: ShareBundleStatus): string {
|
||||
return SHARE_BUNDLE_STATUS_LABELS[status] ?? status
|
||||
statusLabel(status: ShareLinkBundleStatus): string {
|
||||
return SHARE_LINK_BUNDLE_STATUS_LABELS[status] ?? status
|
||||
}
|
||||
|
||||
fileVersionLabel(version: FileVersion): string {
|
||||
return SHARE_BUNDLE_FILE_VERSION_LABELS[version] ?? version
|
||||
return SHARE_LINK_BUNDLE_FILE_VERSION_LABELS[version] ?? version
|
||||
}
|
||||
|
||||
close(): void {
|
||||
this.activeModal.close()
|
||||
}
|
||||
|
||||
private replaceBundle(updated: ShareBundleSummary): void {
|
||||
private replaceBundle(updated: ShareLinkBundleSummary): void {
|
||||
const index = this.bundles.findIndex((bundle) => bundle.id === updated.id)
|
||||
if (index >= 0) {
|
||||
this.bundles = [
|
||||
Reference in New Issue
Block a user