From 7b24f7e3325ec3789a4a69577f366040411df879 Mon Sep 17 00:00:00 2001 From: SiriusXT <1160925501@qq.com> Date: Fri, 1 Nov 2024 20:02:22 +0800 Subject: [PATCH 1/3] close right tabs --- src/public/app/components/tab_manager.js | 14 +++++++++++++- src/public/app/widgets/tab_row.js | 3 ++- src/public/translations/en/translation.json | 1 + 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/public/app/components/tab_manager.js b/src/public/app/components/tab_manager.js index 861a54502..235aa5cd1 100644 --- a/src/public/app/components/tab_manager.js +++ b/src/public/app/components/tab_manager.js @@ -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) { @@ -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); } diff --git a/src/public/app/widgets/tab_row.js b/src/public/app/widgets/tab_row.js index 395dd51d5..cc6f8a22b 100644 --- a/src/public/app/widgets/tab_row.js +++ b/src/public/app/widgets/tab_row.js @@ -260,7 +260,8 @@ 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_other_tabs'), command: "closeOtherTabs", uiIcon: "bx bx-x", enabled: appContext.tabManager.noteContexts.length !== 1}, + {title: t('tab_row.close_right_tabs'), command: "closeRightTabs", uiIcon: "bx bx-x", enabled: appContext.tabManager.noteContexts.at(-1).ntxId !== ntxId}, {title: t('tab_row.close_all_tabs'), command: "closeAllTabs", uiIcon: "bx bx-x"}, {title: t('tab_row.move_tab_to_new_window'), command: "moveTabToNewWindow", uiIcon: "bx bx-window-open"} ], diff --git a/src/public/translations/en/translation.json b/src/public/translations/en/translation.json index 06604c638..dd170d30a 100644 --- a/src/public/translations/en/translation.json +++ b/src/public/translations/en/translation.json @@ -1434,6 +1434,7 @@ "add_new_tab": "Add new tab", "close": "Close", "close_other_tabs": "Close other tabs", + "close_right_tabs": "Close right tabs", "close_all_tabs": "Close all tabs", "move_tab_to_new_window": "Move this tab to a new window", "new_tab": "New tab" From 11a82e62f1836e055f6ce07c9f32f15c5c07c5cf Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Fri, 1 Nov 2024 19:03:06 +0200 Subject: [PATCH 2/3] client: Change layout of tab context menu slightly --- src/public/app/widgets/tab_row.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/public/app/widgets/tab_row.js b/src/public/app/widgets/tab_row.js index cc6f8a22b..ccf49569b 100644 --- a/src/public/app/widgets/tab_row.js +++ b/src/public/app/widgets/tab_row.js @@ -260,9 +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", enabled: appContext.tabManager.noteContexts.length !== 1}, - {title: t('tab_row.close_right_tabs'), command: "closeRightTabs", uiIcon: "bx bx-x", enabled: appContext.tabManager.noteContexts.at(-1).ntxId !== ntxId}, - {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}) => { From d0904c1051e40eae96dde4a8c5eb36ac343252af Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Fri, 1 Nov 2024 19:05:56 +0200 Subject: [PATCH 3/3] client: Change translation for closing tabs to the right --- src/public/translations/en/translation.json | 2 +- src/public/translations/ro/translation.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/public/translations/en/translation.json b/src/public/translations/en/translation.json index dd170d30a..9de64b6bf 100644 --- a/src/public/translations/en/translation.json +++ b/src/public/translations/en/translation.json @@ -1434,7 +1434,7 @@ "add_new_tab": "Add new tab", "close": "Close", "close_other_tabs": "Close other tabs", - "close_right_tabs": "Close right 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" diff --git a/src/public/translations/ro/translation.json b/src/public/translations/ro/translation.json index 6efc98387..b5bff39a8 100644 --- a/src/public/translations/ro/translation.json +++ b/src/public/translations/ro/translation.json @@ -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",