Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/app/mailviewer/singlemailviewer.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
matTooltip="Original HTML" [href]="'/rest/v1/email/'+messageId+'/html'" target="_blank">
<mat-icon svgIcon="alert"></mat-icon>
</a>
<button mat-icon-button *ngIf="morebuttonindex < 12" [matMenuTriggerFor]="moreMailActionsMenu" matTooltip="More message actions">
<button mat-icon-button *ngIf="hasHiddenToolbarActions()" [matMenuTriggerFor]="moreMailActionsMenu" matTooltip="More message actions">
<mat-icon svgIcon="dots-vertical"></mat-icon>
</button>

Expand Down Expand Up @@ -176,16 +176,16 @@
<mat-icon svgIcon="block"></mat-icon>
<span>Block Sender/Domain</span>
</button>
<a *ngIf="morebuttonindex<9" mat-menu-item
<a *ngIf="morebuttonindex<10" mat-menu-item
[href]="'/rest/v1/email/'+messageId+'/raw'" target="_blank">
<mat-icon svgIcon="code-tags"></mat-icon>
<span>View source</span>
</a>
<button mat-menu-item *ngIf="mailContentHTML && morebuttonindex<10" [matMenuTriggerFor]="htmlSettingsMenu">
<button mat-menu-item *ngIf="mailContentHTML && morebuttonindex<11" [matMenuTriggerFor]="htmlSettingsMenu">
<mat-icon svgIcon="cog"></mat-icon>
<span>HTML settings</span>
</button>
<a *ngIf="mailContentHTML && morebuttonindex<11" mat-menu-item
<a *ngIf="mailContentHTML && morebuttonindex<12" mat-menu-item
[href]="'/rest/v1/email/'+messageId+'/html'" target="_blank">
<mat-icon svgIcon="alert"></mat-icon>
<span>Original HTML</span>
Expand Down
23 changes: 23 additions & 0 deletions src/app/mailviewer/singlemailviewer.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,29 @@ describe('SingleMailViewerComponent', () => {
expect(component).toBeTruthy();
});

it('does not show overflow menu for plaintext messages when every plaintext toolbar action fits', () => {
component.mailContentHTML = null;

component.morebuttonindex = 9;
expect(component.hasHiddenToolbarActions()).toBeTrue();

component.morebuttonindex = 10;
expect(component.hasHiddenToolbarActions()).toBeFalse();
});

it('keeps overflow menu visible when HTML-only toolbar actions are hidden', () => {
component.mailContentHTML = '<p>HTML content</p>';

component.morebuttonindex = 10;
expect(component.hasHiddenToolbarActions()).toBeTrue();

component.morebuttonindex = 11;
expect(component.hasHiddenToolbarActions()).toBeTrue();

component.morebuttonindex = 12;
expect(component.hasHiddenToolbarActions()).toBeFalse();
});

it('show mail', fakeAsync(() => {
expect(component).toBeTruthy();

Expand Down
11 changes: 11 additions & 0 deletions src/app/mailviewer/singlemailviewer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ const resizerHeightKey = 'rmm7resizerheight';
const resizerPercentageKey = 'rmm7resizerpercentage';

const TOOLBAR_BUTTON_WIDTH = 30;
const PLAINTEXT_TOOLBAR_ACTION_COUNT = 10;
const HTML_TOOLBAR_ACTION_COUNT = 12;


type Mail = any;
Expand Down Expand Up @@ -331,6 +333,15 @@ export class SingleMailViewerComponent implements OnInit, DoCheck, AfterViewInit
this.attachmentAreaCols = Math.floor(toolbarwidth / 150) + 1;
}
}

/**
* Returns true while the overflow menu contains at least one toolbar action.
*/
public hasHiddenToolbarActions(): boolean {
const actionCount = this.mailContentHTML ? HTML_TOOLBAR_ACTION_COUNT : PLAINTEXT_TOOLBAR_ACTION_COUNT;
return this.morebuttonindex < actionCount;
}

public changeOrientation(orientation: string) {
this.orientationChangeRequest.emit(orientation);
}
Expand Down