Release notes are fetched from GitHub when update checking is enabled.
+ @if (!updateCheckingEnabled()) {
+ @if (!updateCheckingIsSet() && canChangeUpdateChecking) {
+
Paperless-ngx can automatically check for updates and show release notes here, fetched from GitHub.
Release notes are fetched from GitHub when update checking is enabled.
diff --git a/src-ui/src/app/components/common/release-notes-dialog/release-notes-dialog.component.spec.ts b/src-ui/src/app/components/common/release-notes-dialog/release-notes-dialog.component.spec.ts
index b698efef30..560c5c95fd 100644
--- a/src-ui/src/app/components/common/release-notes-dialog/release-notes-dialog.component.spec.ts
+++ b/src-ui/src/app/components/common/release-notes-dialog/release-notes-dialog.component.spec.ts
@@ -7,6 +7,7 @@ import {
import { ComponentFixture, TestBed } from '@angular/core/testing'
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
import { SETTINGS_KEYS } from 'src/app/data/ui-settings'
+import { PermissionsService } from 'src/app/services/permissions.service'
import { SettingsService } from 'src/app/services/settings.service'
import { environment } from 'src/environments/environment'
import {
@@ -20,13 +21,18 @@ describe('ReleaseNotesDialogComponent', () => {
let httpTestingController: HttpTestingController
let settingsService: SettingsService
- function create(updateCheckingEnabled: boolean) {
+ function create(updateCheckingEnabled?: boolean, canChangeSettings = true) {
settingsService = TestBed.inject(SettingsService)
settingsService.set(SETTINGS_KEYS.VERSION, '3.5.1')
- settingsService.set(
- SETTINGS_KEYS.UPDATE_CHECKING_ENABLED,
- updateCheckingEnabled
- )
+ if (updateCheckingEnabled !== undefined) {
+ settingsService.set(
+ SETTINGS_KEYS.UPDATE_CHECKING_ENABLED,
+ updateCheckingEnabled
+ )
+ }
+ jest
+ .spyOn(TestBed.inject(PermissionsService), 'currentUserCan')
+ .mockReturnValue(canChangeSettings)
fixture = TestBed.createComponent(ReleaseNotesDialogComponent)
component = fixture.componentInstance
}
@@ -122,6 +128,53 @@ describe('ReleaseNotesDialogComponent', () => {
)
})
+ it('should offer to enable update checking if never chosen', () => {
+ create()
+ const chosen = jest.fn()
+ component.updateCheckingChosen.subscribe(chosen)
+ component.load('3.4.2')
+ fixture.detectChanges()
+
+ const enable = Array.from(
+ fixture.nativeElement.querySelectorAll('.modal-body button')
+ ).find((b: HTMLButtonElement) => b.textContent.trim() === 'Enable') as
+ HTMLButtonElement | undefined
+ expect(enable).toBeTruthy()
+ httpTestingController.expectNone(`${environment.apiBaseUrl}release_notes/`)
+
+ enable.click()
+ expect(chosen).toHaveBeenCalledWith(true)
+ httpTestingController
+ .expectOne(`${environment.apiBaseUrl}release_notes/?since=3.4.2`)
+ .flush({ version: '3.5.1', releases: [] })
+ })
+
+ it('should show the disabled message after choosing disable', () => {
+ create()
+ const chosen = jest.fn()
+ component.updateCheckingChosen.subscribe(chosen)
+ component.load(null)
+ component.setUpdateChecking(false)
+ fixture.detectChanges()
+
+ expect(chosen).toHaveBeenCalledWith(false)
+ httpTestingController.expectNone(`${environment.apiBaseUrl}release_notes/`)
+ expect(fixture.nativeElement.textContent).toContain(
+ 'when update checking is enabled'
+ )
+ })
+
+ it('should not offer to enable update checking without permission', () => {
+ create(undefined, false)
+ component.load(null)
+ fixture.detectChanges()
+
+ expect(fixture.nativeElement.textContent).not.toContain('Enable')
+ expect(fixture.nativeElement.textContent).toContain(
+ 'when update checking is enabled'
+ )
+ })
+
it('should support close', () => {
create(false)
const closeSpy = jest.spyOn(component.activeModal, 'close')
diff --git a/src-ui/src/app/components/common/release-notes-dialog/release-notes-dialog.component.ts b/src-ui/src/app/components/common/release-notes-dialog/release-notes-dialog.component.ts
index d9fec36c07..1883daa1de 100644
--- a/src-ui/src/app/components/common/release-notes-dialog/release-notes-dialog.component.ts
+++ b/src-ui/src/app/components/common/release-notes-dialog/release-notes-dialog.component.ts
@@ -1,10 +1,15 @@
import { DecimalPipe, NgTemplateOutlet } from '@angular/common'
-import { Component, inject, signal } from '@angular/core'
+import { Component, inject, output, signal } from '@angular/core'
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
import { first } from 'rxjs'
import { BootstrapIconComponent } from 'src/app/components/common/bootstrap-icon/bootstrap-icon.component'
import { SETTINGS_KEYS } from 'src/app/data/ui-settings'
import { CustomDatePipe } from 'src/app/pipes/custom-date.pipe'
+import {
+ PermissionAction,
+ PermissionsService,
+ PermissionType,
+} from 'src/app/services/permissions.service'
import {
AppRelease,
RemoteVersionService,
@@ -49,6 +54,7 @@ export class ReleaseNotesDialogComponent {
readonly activeModal = inject(NgbActiveModal)
private readonly remoteVersionService = inject(RemoteVersionService)
private readonly settingsService = inject(SettingsService)
+ private readonly permissionsService = inject(PermissionsService)
readonly since = signal
(null)
readonly releases = signal(null)
@@ -56,9 +62,18 @@ export class ReleaseNotesDialogComponent {
readonly loading = signal(false)
readonly version: string = this.settingsService.get(SETTINGS_KEYS.VERSION)
- readonly updateCheckingEnabled: boolean = this.settingsService.get(
- SETTINGS_KEYS.UPDATE_CHECKING_ENABLED
+ readonly updateCheckingEnabled = signal(
+ this.settingsService.get(SETTINGS_KEYS.UPDATE_CHECKING_ENABLED)
)
+ readonly updateCheckingIsSet = signal(
+ this.settingsService.updateCheckingIsSet
+ )
+ readonly canChangeUpdateChecking = this.permissionsService.currentUserCan(
+ PermissionAction.Change,
+ PermissionType.UISettings
+ )
+
+ readonly updateCheckingChosen = output()
readonly repoUrl = REPO_URL
readonly releasesUrl = RELEASES_URL
@@ -74,7 +89,7 @@ export class ReleaseNotesDialogComponent {
*/
load(since: string | null): void {
this.since.set(since)
- if (!this.updateCheckingEnabled) return
+ if (!this.updateCheckingEnabled()) return
this.loading.set(true)
this.remoteVersionService
.getReleaseNotes(since ?? undefined)
@@ -97,6 +112,13 @@ export class ReleaseNotesDialogComponent {
})
}
+ setUpdateChecking(enable: boolean): void {
+ this.updateCheckingIsSet.set(true)
+ this.updateCheckingEnabled.set(enable)
+ this.updateCheckingChosen.emit(enable)
+ if (enable) this.load(this.since())
+ }
+
close(): void {
this.activeModal.close()
}