diff --git a/src-ui/src/app/components/manage/share-links/share-link-bundle-list/share-link-bundle-list.component.html b/src-ui/src/app/components/manage/share-links/share-link-bundle-list/share-link-bundle-list.component.html index b2bf5cc9d..62a680964 100644 --- a/src-ui/src/app/components/manage/share-links/share-link-bundle-list/share-link-bundle-list.component.html +++ b/src-ui/src/app/components/manage/share-links/share-link-bundle-list/share-link-bundle-list.component.html @@ -80,6 +80,9 @@ @if (bundle.expiration) { {{ bundle.expiration | date: 'short' }} + @if (isExpired(bundle.expiration)) { + Expired + } } @if (!bundle.expiration) { Never diff --git a/src-ui/src/app/components/manage/share-links/share-link-bundle-list/share-link-bundle-list.component.spec.ts b/src-ui/src/app/components/manage/share-links/share-link-bundle-list/share-link-bundle-list.component.spec.ts index 618610fc2..362d99e0a 100644 --- a/src-ui/src/app/components/manage/share-links/share-link-bundle-list/share-link-bundle-list.component.spec.ts +++ b/src-ui/src/app/components/manage/share-links/share-link-bundle-list/share-link-bundle-list.component.spec.ts @@ -123,6 +123,19 @@ describe('ShareLinkBundleListComponent', () => { expect(service.list).toHaveBeenLastCalledWith(2, 25, 'created', true) }) + it('marks expired share link bundles', () => { + service.list.mockReturnValue( + of({ + count: 1, + results: [sampleBundle({ expiration: '2000-01-01T00:00:00.000Z' })], + }) + ) + + fixture.detectChanges() + + expect(fixture.nativeElement.textContent).toContain('Expired') + }) + it('stores a changed page size and reloads from the first page', () => { fixture.detectChanges() const settingsService = TestBed.inject(SettingsService) diff --git a/src-ui/src/app/components/manage/share-links/share-link-bundle-list/share-link-bundle-list.component.ts b/src-ui/src/app/components/manage/share-links/share-link-bundle-list/share-link-bundle-list.component.ts index 2497b2614..a8dc8ed4d 100644 --- a/src-ui/src/app/components/manage/share-links/share-link-bundle-list/share-link-bundle-list.component.ts +++ b/src-ui/src/app/components/manage/share-links/share-link-bundle-list/share-link-bundle-list.component.ts @@ -195,6 +195,10 @@ export class ShareLinkBundleListComponent return SHARE_LINK_BUNDLE_FILE_VERSION_LABELS[version] ?? version } + isExpired(expiration?: string): boolean { + return !!expiration && Date.parse(expiration) <= Date.now() + } + private replaceBundle(updated: ShareLinkBundleSummary): void { const bundles = this.bundles() const index = bundles.findIndex((bundle) => bundle.id === updated.id) diff --git a/src-ui/src/app/components/manage/share-links/share-link-list/share-link-list.component.html b/src-ui/src/app/components/manage/share-links/share-link-list/share-link-list.component.html index d2cb78c88..25c90f64c 100644 --- a/src-ui/src/app/components/manage/share-links/share-link-list/share-link-list.component.html +++ b/src-ui/src/app/components/manage/share-links/share-link-list/share-link-list.component.html @@ -36,6 +36,9 @@ @if (link.expiration) { {{ link.expiration | date: 'short' }} + @if (isExpired(link.expiration)) { + Expired + } } @else { Never } diff --git a/src-ui/src/app/components/manage/share-links/share-link-list/share-link-list.component.spec.ts b/src-ui/src/app/components/manage/share-links/share-link-list/share-link-list.component.spec.ts index 02de8b43b..43a6f7cc0 100644 --- a/src-ui/src/app/components/manage/share-links/share-link-list/share-link-list.component.spec.ts +++ b/src-ui/src/app/components/manage/share-links/share-link-list/share-link-list.component.spec.ts @@ -75,6 +75,24 @@ describe('ShareLinkListComponent', () => { expect(service.list).toHaveBeenLastCalledWith(2, 25, 'created', true) }) + it('marks expired share links', () => { + service.list.mockReturnValue( + of({ + count: 1, + results: [ + { + ...link, + expiration: '2000-01-01T00:00:00.000Z', + }, + ], + }) + ) + + fixture.detectChanges() + + expect(fixture.nativeElement.textContent).toContain('Expired') + }) + it('stores a changed page size and reloads from the first page', () => { const settingsService = TestBed.inject(SettingsService) jest.spyOn(settingsService, 'get').mockReturnValueOnce({ share_links: 25 }) diff --git a/src-ui/src/app/components/manage/share-links/share-link-list/share-link-list.component.ts b/src-ui/src/app/components/manage/share-links/share-link-list/share-link-list.component.ts index 36dc6835b..8c4239256 100644 --- a/src-ui/src/app/components/manage/share-links/share-link-list/share-link-list.component.ts +++ b/src-ui/src/app/components/manage/share-links/share-link-list/share-link-list.component.ts @@ -120,6 +120,10 @@ export class ShareLinkListComponent return SHARE_LINK_BUNDLE_FILE_VERSION_LABELS[version] ?? version } + isExpired(expiration?: string): boolean { + return !!expiration && Date.parse(expiration) <= Date.now() + } + copy(link: ShareLink): void { if (this.clipboard.copy(this.getShareUrl(link))) { this.copiedID.set(link.id)