Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8007 keyboard shortcut for labels #8042

Merged
merged 1 commit into from
Dec 4, 2024
Merged
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
38 changes: 35 additions & 3 deletions src/mail-app/mail/view/MailView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Dialog } from "../../../common/gui/base/Dialog"
import { FeatureType, Keys, MailSetKind } from "../../../common/api/common/TutanotaConstants"
import { AppHeaderAttrs, Header } from "../../../common/gui/Header.js"
import type { Mail, MailBox, MailFolder } from "../../../common/api/entities/tutanota/TypeRefs.js"
import { noOp, ofClass } from "@tutao/tutanota-utils"
import { isEmpty, noOp, ofClass } from "@tutao/tutanota-utils"
import { MailListView } from "./MailListView"
import { assertMainOrNode, isApp } from "../../../common/api/common/Env"
import type { Shortcut } from "../../../common/misc/KeyManager"
Expand Down Expand Up @@ -70,6 +70,7 @@ import { ButtonSize } from "../../../common/gui/base/ButtonSize"
import { RowButton } from "../../../common/gui/base/buttons/RowButton"
import { getLabelColor } from "../../../common/gui/base/Label.js"
import { MAIL_PREFIX } from "../../../common/misc/RouteChange"
import { LabelsPopup } from "./LabelsPopup"

assertMainOrNode()

Expand Down Expand Up @@ -233,10 +234,9 @@ export class MailView extends BaseTopLevelView implements TopLevelView<MailViewA
this.viewSlider.focusedColumn = this.listColumn

const shortcuts = this.getShortcuts()

vnode.attrs.mailViewModel.init()

this.oncreate = () => {
this.oncreate = (vnode) => {
this.countersStream = mailLocator.mailModel.mailboxCounters.map(m.redraw)
keyManager.registerShortcuts(shortcuts)
this.cache.conversationViewPreference = deviceConfig.getConversationViewShowOnlySelectedMail()
Expand Down Expand Up @@ -473,6 +473,14 @@ export class MailView extends BaseTopLevelView implements TopLevelView<MailViewA
},
help: "move_action",
},
{
key: Keys.L,
exec: () => {
this.labels()
return true
},
help: "labels_label",
},
{
key: Keys.U,
exec: () => {
Expand Down Expand Up @@ -564,6 +572,30 @@ export class MailView extends BaseTopLevelView implements TopLevelView<MailViewA
showMoveMailsDropdown(locator.mailboxModel, mailLocator.mailModel, getMoveMailBounds(), selectedMails)
}

/**
*Shortcut Method to show Labels dropdown only when atleast one mail is selected.
*/
private labels() {
const mailList = this.mailViewModel.listModel
if (mailList == null) {
return
}

const selectedMails = mailList.getSelectedAsArray()
if (isEmpty(selectedMails)) {
return
}

const popup = new LabelsPopup(
document.activeElement as HTMLElement,
getMoveMailBounds(),
styles.isDesktopLayout() ? 300 : 200,
mailLocator.mailModel.getLabelStatesForMails(selectedMails),
(addedLabels, removedLabels) => mailLocator.mailModel.applyLabels(selectedMails, addedLabels, removedLabels),
)
popup.show()
}

private createFolderColumn(editingFolderForMailGroup: Id | null = null, drawerAttrs: DrawerMenuAttrs) {
return new ViewColumn(
{
Expand Down
Loading