mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-16 01:31:09 -06:00
Hide button if not enabled should be in details
This commit is contained in:
@@ -8,7 +8,6 @@ import { of, throwError } from 'rxjs'
|
||||
import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive'
|
||||
import { PermissionsService } from 'src/app/services/permissions.service'
|
||||
import { DocumentService } from 'src/app/services/rest/document.service'
|
||||
import { SettingsService } from 'src/app/services/settings.service'
|
||||
import { ToastService } from 'src/app/services/toast.service'
|
||||
import { EmailDocumentDialogComponent } from './email-document-dialog.component'
|
||||
|
||||
@@ -40,12 +39,6 @@ describe('EmailDocumentDialogComponent', () => {
|
||||
fixture.detectChanges()
|
||||
})
|
||||
|
||||
it('should get email enabled status from settings', () => {
|
||||
const settingsService = TestBed.inject(SettingsService)
|
||||
jest.spyOn(settingsService, 'get').mockReturnValue(true)
|
||||
expect(component.emailEnabled).toBeTruthy()
|
||||
})
|
||||
|
||||
it('should set hasArchiveVersion and useArchiveVersion', () => {
|
||||
expect(component.hasArchiveVersion).toBeTruthy()
|
||||
component.hasArchiveVersion = false
|
||||
|
||||
@@ -2,9 +2,7 @@ import { Component, Input } from '@angular/core'
|
||||
import { FormsModule } from '@angular/forms'
|
||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
|
||||
import { NgxBootstrapIconsModule } from 'ngx-bootstrap-icons'
|
||||
import { SETTINGS_KEYS } from 'src/app/data/ui-settings'
|
||||
import { DocumentService } from 'src/app/services/rest/document.service'
|
||||
import { SettingsService } from 'src/app/services/settings.service'
|
||||
import { ToastService } from 'src/app/services/toast.service'
|
||||
import { LoadingComponentWithPermissions } from '../../loading-component/loading.component'
|
||||
|
||||
@@ -39,15 +37,10 @@ export class EmailDocumentDialogComponent extends LoadingComponentWithPermission
|
||||
public emailSubject: string = ''
|
||||
public emailMessage: string = ''
|
||||
|
||||
get emailEnabled(): boolean {
|
||||
return this.settingsService.get(SETTINGS_KEYS.EMAIL_ENABLED)
|
||||
}
|
||||
|
||||
constructor(
|
||||
private activeModal: NgbActiveModal,
|
||||
private documentService: DocumentService,
|
||||
private toastService: ToastService,
|
||||
private settingsService: SettingsService
|
||||
private toastService: ToastService
|
||||
) {
|
||||
super()
|
||||
this.loading = false
|
||||
|
||||
@@ -91,9 +91,11 @@
|
||||
<button ngbDropdownItem (click)="openShareLinks()" [disabled]="!userCanEdit || !userIsOwner" *pngxIfPermissions="{ action: PermissionAction.Add, type: PermissionType.ShareLink }">
|
||||
<i-bs name="link"></i-bs> <span i18n>Share Links</span>
|
||||
</button>
|
||||
<button ngbDropdownItem (click)="openEmailDocument()" [disabled]="!userCanEdit || !userIsOwner">
|
||||
<i-bs name="envelope"></i-bs> <span i18n>Email</span>
|
||||
</button>
|
||||
@if (emailEnabled) {
|
||||
<button ngbDropdownItem (click)="openEmailDocument()" [disabled]="!userCanEdit || !userIsOwner">
|
||||
<i-bs name="envelope"></i-bs> <span i18n>Email</span>
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1331,6 +1331,11 @@ describe('DocumentDetailComponent', () => {
|
||||
expect(urlRevokeSpy).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('should get email enabled status from settings', () => {
|
||||
jest.spyOn(settingsService, 'get').mockReturnValue(true)
|
||||
expect(component.emailEnabled).toBeTruthy()
|
||||
})
|
||||
|
||||
it('should support open share links and email modals', () => {
|
||||
const modalSpy = jest.spyOn(modalService, 'open')
|
||||
initNormally()
|
||||
|
||||
@@ -1433,6 +1433,10 @@ export class DocumentDetailComponent
|
||||
!!this.document?.archived_file_name
|
||||
}
|
||||
|
||||
get emailEnabled(): boolean {
|
||||
return this.settings.get(SETTINGS_KEYS.EMAIL_ENABLED)
|
||||
}
|
||||
|
||||
public openEmailDocument() {
|
||||
const modal = this.modalService.open(EmailDocumentDialogComponent, {
|
||||
backdrop: 'static',
|
||||
|
||||
Reference in New Issue
Block a user