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

close right tabs #542

Merged
merged 3 commits into from
Nov 1, 2024
Merged
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
14 changes: 13 additions & 1 deletion src/public/app/components/tab_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ export default class TabManager extends Component {
await this.removeNoteContext(ntxIdToRemove);
}
}

async closeOtherTabsCommand({ntxId}) {
for (const ntxIdToRemove of this.mainNoteContexts.map(nc => nc.ntxId)) {
if (ntxIdToRemove !== ntxId) {
Expand All @@ -560,6 +560,18 @@ export default class TabManager extends Component {
}
}

async closeRightTabsCommand({ntxId}) {
const ntxIds = this.mainNoteContexts.map(nc => nc.ntxId);
const index = ntxIds.indexOf(ntxId);

if (index !== -1) {
const idsToRemove = ntxIds.slice(index + 1);
for (const ntxIdToRemove of idsToRemove) {
await this.removeNoteContext(ntxIdToRemove);
}
}
}

async closeTabCommand({ntxId}) {
await this.removeNoteContext(ntxId);
}
Expand Down
6 changes: 4 additions & 2 deletions src/public/app/widgets/tab_row.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,10 @@ export default class TabRowWidget extends BasicWidget {
y: e.pageY,
items: [
{title: t('tab_row.close'), command: "closeTab", uiIcon: "bx bx-x"},
{title: t('tab_row.close_other_tabs'), command: "closeOtherTabs", uiIcon: "bx bx-x"},
{title: t('tab_row.close_all_tabs'), command: "closeAllTabs", uiIcon: "bx bx-x"},
{title: t('tab_row.close_other_tabs'), command: "closeOtherTabs", uiIcon: "bx bx-empty", enabled: appContext.tabManager.noteContexts.length !== 1},
{title: t('tab_row.close_right_tabs'), command: "closeRightTabs", uiIcon: "bx bx-empty", enabled: appContext.tabManager.noteContexts.at(-1).ntxId !== ntxId},
{title: t('tab_row.close_all_tabs'), command: "closeAllTabs", uiIcon: "bx bx-empty"},
{ title: "----" },
{title: t('tab_row.move_tab_to_new_window'), command: "moveTabToNewWindow", uiIcon: "bx bx-window-open"}
],
selectMenuItemHandler: ({command}) => {
Expand Down
1 change: 1 addition & 0 deletions src/public/translations/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1434,6 +1434,7 @@
"add_new_tab": "Add new tab",
"close": "Close",
"close_other_tabs": "Close other tabs",
"close_right_tabs": "Close tabs to the right",
"close_all_tabs": "Close all tabs",
"move_tab_to_new_window": "Move this tab to a new window",
"new_tab": "New tab"
Expand Down
3 changes: 2 additions & 1 deletion src/public/translations/ro/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1439,7 +1439,8 @@
"close_other_tabs": "Închide celelalte taburi",
"close_tab": "Închide tab",
"move_tab_to_new_window": "Mută acest tab în altă fereastră",
"new_tab": "Tab nou"
"new_tab": "Tab nou",
"close_right_tabs": "Închide taburile din dreapta"
},
"toc": {
"options": "Setări",
Expand Down