Skip to content

Commit

Permalink
Add option to duplicate tab to window menu (#2663)
Browse files Browse the repository at this point in the history
Task/Issue URL:
https://app.asana.com/0/1199230911884351/1207114296893342/f
Tech Design URL:
CC: @ayoy 

**Description**:
This PR adds the option to duplicate a tab to the window menu

**Steps to test this PR**:
1. Open a tab
2. Click window > duplicate tab
3. The current tab should be duplicated, if the tab is pinned the
duplicated tab should also be pinned.

<!--
Tagging instructions
If this PR isn't ready to be merged for whatever reason it should be
marked with the `DO NOT MERGE` label (particularly if it's a draft)
If it's pending Product Review/PFR, please add the `Pending Product
Review` label.

If at any point it isn't actively being worked on/ready for
review/otherwise moving forward (besides the above PR/PFR exception)
strongly consider closing it (or not opening it in the first place). If
you decide not to close it, make sure it's labelled to make it clear the
PRs state and comment with more information.
-->

---
###### Internal references:
[Pull Request Review
Checklist](https://app.asana.com/0/1202500774821704/1203764234894239/f)
[Software Engineering
Expectations](https://app.asana.com/0/59792373528535/199064865822552)
[Technical Design
Template](https://app.asana.com/0/59792373528535/184709971311943)
[Pull Request
Documentation](https://app.asana.com/0/1202500774821704/1204012835277482/f)
  • Loading branch information
SlayterDev authored Apr 18, 2024
1 parent 1b0f864 commit 792b6ed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions DuckDuckGo/Menus/MainMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ import SubscriptionUI
NSMenuItem(title: UserText.zoom, action: #selector(NSWindow.performZoom))
NSMenuItem.separator()

NSMenuItem(title: UserText.duplicateTab, action: #selector(MainViewController.duplicateTab))
NSMenuItem(title: UserText.pinTab, action: #selector(MainViewController.pinOrUnpinTab))
NSMenuItem(title: UserText.moveTabToNewWindow, action: #selector(MainViewController.moveTabToNewWindow))
NSMenuItem(title: UserText.mainMenuWindowMergeAllWindows, action: #selector(NSWindow.mergeAllWindows))
Expand Down
6 changes: 6 additions & 0 deletions DuckDuckGo/Menus/MainMenuActions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,12 @@ extension MainViewController {
WindowsManager.openNewWindow(with: tab)
}

@objc func duplicateTab(_ sender: Any?) {
guard let (_, index) = getActiveTabAndIndex() else { return }

tabCollectionViewModel.duplicateTab(at: index)
}

@objc func pinOrUnpinTab(_ sender: Any?) {
guard let (_, selectedTabIndex) = getActiveTabAndIndex() else { return }

Expand Down

0 comments on commit 792b6ed

Please sign in to comment.