Hide button if not enabled should be in details

This commit is contained in:
shamoon
2025-02-12 23:00:18 -08:00
parent 9310cea495
commit ccbdb155f8
6 changed files with 56 additions and 59 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -91,9 +91,11 @@
<button ngbDropdownItem (click)="openShareLinks()" [disabled]="!userCanEdit || !userIsOwner" *pngxIfPermissions="{ action: PermissionAction.Add, type: PermissionType.ShareLink }">
<i-bs name="link"></i-bs>&nbsp;<span i18n>Share Links</span>
</button>
<button ngbDropdownItem (click)="openEmailDocument()" [disabled]="!userCanEdit || !userIsOwner">
<i-bs name="envelope"></i-bs>&nbsp;<span i18n>Email</span>
</button>
@if (emailEnabled) {
<button ngbDropdownItem (click)="openEmailDocument()" [disabled]="!userCanEdit || !userIsOwner">
<i-bs name="envelope"></i-bs>&nbsp;<span i18n>Email</span>
</button>
}
</div>
</div>

View File

@@ -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()

View File

@@ -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',